// What is $(document).ready ? See: http://flowplayer.org/tools/using.html#document_ready
 
$(document).ready(function() { 
	
	// initialize tooltip
	$("#accessoptions img[title]").tooltip({
	
		// use single tooltip element for all tips
		tip: '#dynatip', 
		delay: 0,
		position: "top left",
		lazy:false,
		// tweak the position
		offset: [10, 25]
	});
	
	$('#accessoptions img.img1').click(function(){
		$(this).fadeTo('slow', 0.3);
		iid = $(this).attr('id');
		optionId = iid.split('_');		
		var selected_opt = $('#selected_options1').val();
		if(selected_opt==''){
			var opt = ','+optionId[1]+',';
		}else{
			var opt = optionId[1]+',';
		}
		var div_optt = "div_"+optionId[1];
		$('#'+div_optt).show();
		var selected_options1 = selected_opt+opt;
		$('#selected_options1').val(selected_options1);
		return false;
	});

	$('#accessoptions div.div_img2').click(function(){
		iid = $(this).attr('id');
		optionId = iid.split('_');
		var option_values = $('#selected_options1').val();
		var new_str = option_values.replace(","+optionId[1]+",", ",");		
		$('#selected_options1').val(new_str);
		var div_optt = "div_"+optionId[1];
		$('#'+div_optt).hide();
		var img_opt = "opt_"+optionId[1];
		$("#"+img_opt).fadeTo('slow', 1);
		return false;
	});
	
	// initialize tooltip
		
	$("#moreaccessoptions img[title]").tooltip({	
	
		// use single tooltip element for all tips
		tip: '#dynatip', 
		delay: 0,
		position: "top left",
		lazy:false,
		// tweak the position
		offset: [05, 25]
	});
	
	$('#moreaccessoptions img.img1').click(function(){
		$(this).fadeTo('slow', 0.3);
		iid = $(this).attr('id');
		optionId = iid.split('_');
		var selected_opt = $('#selected_options1').val();
		if(selected_opt==''){
			var opt = ','+optionId[1]+',';
		}else{
			var opt = optionId[1]+',';
		}
		var selected_options1 = selected_opt+opt;
		$('#selected_options1').val(selected_options1);

		var div_optt = "div_"+optionId[1];
		$('#'+div_optt).show();

		return false;
	});

	 $('#moreaccessoptions div.div_img2').click(function(){
		iid = $(this).attr('id');
		optionId = iid.split('_');
		var option_values = $('#selected_options1').val();
		var new_str = option_values.replace(","+optionId[1]+",", ",");
		$('#selected_options1').val(new_str);

		var div_optt = "div_"+optionId[1];
		$('#'+div_optt).hide();

		var img_opt = "opt_"+optionId[1];
		$("#"+img_opt).fadeTo('slow', 1);

		return false;
	});	
		
	//$('#morediv').hide();
 
  /*$('a#linkoptions').click(function(){
	$(this).toggleClass('upArrowHome_more');
   $('#morediv').slideToggle();
    return false;
  });*/


$('a#linkselectoptions').click(function(){
	$(this).toggleClass('upArrowHome');
	if($('#morediv').is(':visible')){
		$('#moreaccessoptions').hide();
	} else {
		$('#moreaccessoptions').show();
	}
	$('#morediv').slideToggle('slow', function() {
    // Animation complete.
	});
    return false;
  });
   
  	$.post("/welcome/changestoretype/"+$('#storetype').val(),{},function(data){			
	});

	$("#keyword").autocomplete("/welcome/autosuggest", {
		width: 365,
		matchContains: false,
		minChars: 1,
		mustMatch: false,
		selectFirst: false
	});
	
	$("#keyword").result(function(event, data, formatted) {
	}); 

	$('#toggle_results').click(function(){
		val1 = $(this).html();
		if(val1=='Hide Results'){
			$(this).html('Show Results');
		}else{
			$(this).html('Hide Results');
		}
		$('#st_loc').slideToggle();
	})

});


function changeCountryBg(cid,lid,continentId){
	$("#"+cid).addClass('changeCountryBg');
}

function removeCountryBg(cid,lid,continentId){
	$("#"+cid).removeClass('changeCountryBg');
}

function changeContinentBg(lid,continentId){
	$("#contnent_"+continentId).removeClass('continentname');
	if($("#contnent_"+continentId).className!='changeContinentTxt')
	{
		document.getElementById(lid).style.background='#015788';
		$("#contnent_"+continentId).addClass('changeContinentTxt');
	}	
		
}

function removeContinentBg(lid,continentId)
{
	$("#contnent_"+continentId).removeClass('changeContinentTxt');

	if($("#contnent_"+continentId).className!='continentname')
	{
		document.getElementById(lid).style.background='#cccccc';
		$("#contnent_"+continentId).addClass('continentname');
	}
}

function toggle_button(element,mode){
	if(mode==1){
		$('#'+element).removeClass('button_submit');
		$('#'+element).addClass('button_submit_hover');
	}else{
		$('#'+element).removeClass('button_submit_hover');
		$('#'+element).addClass('button_submit');		
	}
}

function gotFocus(ctl,val)
{

    if(document.getElementById(ctl).value==val)
    {
        document.getElementById(ctl).value='';
    }
}
function lostFocus(ctl,val)
{
    if(document.getElementById(ctl).value=='')
    {
        document.getElementById(ctl).value=val;
    }
}



