// JavaScript Document
var windowWidth, windowHeight;
var arrNotations = new Array();

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  
  return true
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  
  windowWidth = myWidth;
  windowHeight = myHeight;
}

alertSize();

function showLayer(){
	//alert(navigator.appVersion);
	if(navigator.appName == "Opera"){
		document.getElementById('footer').style.top = '-176px';
	}
	else if(navigator.appName == "Netscape"){
		// no need to change
	}
	else if(navigator.appName == "Microsoft Internet Explorer"){
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 	if (ieversion>=8){
		  		document.getElementById('footer').style.top = '-176px';
			}
			else if (ieversion>=7){
		  		document.getElementById('footer').style.top = '-176px';
			}
			else if (ieversion>=6){
		  		document.getElementById('footer').style.top = '-176px';
			}
			else if (ieversion>=5){
		  		document.getElementById('footer').style.top = '-176px';
			}
		}
		else{
			document.getElementById('footer').style.top = '-176px';
		}
	}
	
	//document.getElementById('home_shopping_girl').style.display = 'block';
}

function callChangePNG(){
	//alert(navigator.appVersion);
	if(navigator.appName == "Microsoft Internet Explorer"){
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 	if (ieversion>=6){
				changePNG();
			}
			else if (ieversion>=5){
		  		changePNG();
			}
		}
	}
	
}

function showContactLayer(){
	//alert(navigator.appVersion );
	if(navigator.appName == "Opera"){
		document.getElementById('contact_us_shopping_girl').style.bottom = '49px';
	}
	else if(navigator.appName == "Netscape"){
		// no need to change
	}
	else if(navigator.appName == "Microsoft Internet Explorer"){
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 	if (ieversion>=8){
		  		//document.getElementById('contact_us_shopping_girl').style.bottom = '27px';
				//document.getElementById('contact_us_shopping_girl').style.left = '78px';
			}
			else if (ieversion>=7){
		  		document.getElementById('contact_us_shopping_girl').style.bottom = '27px';
				document.getElementById('contact_us_shopping_girl').style.left = '78px';
			}
			else if (ieversion>=6){
		  		document.getElementById('contact_us_shopping_girl').style.bottom = '-40px';
				document.getElementById('contact_us_shopping_girl').style.left = '78px';
			}
			else if (ieversion>=5){
		  		document.getElementById('contact_us_shopping_girl').style.bottom = '-40px';
				document.getElementById('contact_us_shopping_girl').style.left = '78px';
			}
		}
		else{
			document.getElementById('contact_us_shopping_girl').style.bottom = '-40px';
			document.getElementById('contact_us_shopping_girl').style.left = '78px';
		}
	}
	
	document.getElementById('contact_us_shopping_girl').style.display = 'block';
}

function activeThis(str){
	var div_name = "slected_menu_"+str;
	document.getElementById('slected_menu').className = div_name;
}

function inactiveThis(){
	var div_name = "slected_menu_"+selectedMenu;
	document.getElementById('slected_menu').className = div_name;
}

function gotoThis(str){
	window.location = str;
}

function changePNG(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version < 7) && (version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
}

function showStore(str){
	document.getElementById('popup_content').innerHTML = str;
}

function showLoader(str){
	//if(navigator.appName != "Microsoft Internet Explorer"){
	//	document.getElementById('popup_bg').style.height = Number(document.getElementById('content_div').clientHeight-40)+"px";
	//}
	//else{
	//	document.getElementById('popup_bg').style.height = document.getElementById('content_div').clientHeight+"px";
	//}
	
	document.getElementById('popup').style.left = tempX+'px';
	document.getElementById('popup').style.top = tempY+'px';

	document.getElementById('popup_content').innerHTML = str;
	
	//document.getElementById('popup_bg').style.display = "block";
	
	document.getElementById('popup').style.display = "block";
}

function hideStore(){
	try{
		//document.getElementById('popup_bg').style.display = "none";
		document.getElementById('popup').style.display = "none";
	}
	catch(e){
	}
}

function showMouseOver(str){
	//document.getElementById('a_'+str).style.textDecoration = "underline";
}

function showMouseOut(str){
	hideStore();
	//document.getElementById('a_'+str).style.textDecoration = "none";
}

//AJAX START
function createXMLHttpRequest() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
}

function getStore(store_id, call_from)
{ 
	var req = null; 
	
	req = createXMLHttpRequest();
	
	showLoader('Loading...');
	
	req.onreadystatechange = function()
	{ 
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				if(req.responseText == "error"){
					hideStore();
					alert('Error!');
				}
				else{
					showStore(req.responseText);
				}
			}	
			else	
			{
				hideStore();
				alert('Error!');
			}	
		} 
	}; 
	var getString = "ajaxGetStore.html?store_id="+store_id+"&call_from="+call_from;
	//alert(getString);
	req.open("GET", getString, true); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(null); 
} 


function getEvent(event_id)
{ 
	var req = null; 
	
	req = createXMLHttpRequest();
	
	document.getElementById('popup').style.top = 300+'px';
	showLoader('Loading...');
	
	req.onreadystatechange = function()
	{ 
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				if(req.responseText == "error"){
					hideStore();
					alert('Error!');
				}
				else{
					showStore(req.responseText);
				}
			}	
			else	
			{
				hideStore();
				alert('Error!');
			}	
		} 
	}; 
	var getString = "ajaxGetEvent.html?event_id="+event_id;
	//alert(getString);
	req.open("GET", getString, true); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(null); 
} 

function showLocation(){
	if(navigator.appName != "Microsoft Internet Explorer"){
		document.getElementById('popup_location_bg').style.height = Number(document.getElementById('content_div').clientHeight-40)+"px";
	}
	else{
		document.getElementById('popup_location_bg').style.height = document.getElementById('content_div').clientHeight+"px";
	}
	
	document.getElementById('popup_location_bg').style.height = 880+"px";
	
	document.getElementById('popup_location_bg').style.display = "block";
	
	document.getElementById('popup_location').style.display = "block";
	
}

function hideLocation(){
	document.getElementById('popup_location_bg').style.display = "none";
	
	document.getElementById('popup_location').style.display = "none";
	
}

function redirectTo(str,type){
	if(type == "_blank"){
		window.open(str,type);
	}
	else{
		window.location = str;
	}
}

function fixEventCell(){
	var maxH = 0;
	try{
		for(i=1; i<31; i++){
			var str = 'd_'+i;
			var temp = document.getElementById(str).style.height;
			//alert('dd'+temp);
			if(Number(maxH) < Number(temp)){
				maxH = temp;
			}
		}
		
	}
	catch(e){
	}
	
	//alert(maxH);
}

function getEventList(val_date, val_month, val_year)
{ 
	var req = null; 
	
	req = createXMLHttpRequest();
	
	document.getElementById('popup').style.top = 300+'px';
	showLoader('Loading...');
	
	req.onreadystatechange = function()
	{ 
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				if(req.responseText == "error"){
					hideEventList();
					//alert('Error!');
				}
				else{
					showStore(req.responseText);
				}
			}	
			else	
			{
				hideEventList();
				//alert('Error!');
			}	
		} 
	}; 
	var getString = "ajaxGetAllEventsByDate.html?val_date="+val_date+"&val_month="+val_month+"&val_year="+val_year;
	//alert(getString);
	req.open("GET", getString, true); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(null); 
} 

function hideEventList(){
	try{
		//document.getElementById('popup_bg').style.display = "none";
		document.getElementById('popup').style.display = "none";
	}
	catch(e){
	}
}

