
//Global Variables--------------------------------------------------->
	var myWidth = 0;
	var myHeight = 0;
	
	var IE = document.all?true:false
		
	var posX = 0;
	var posY = 0;
	
	var loadState=0;
	
	var currTtp;
	var showTtp=false;
//Global Variables---------------------------------------------------|



//Initialize Variables----------------------------------------------->
	getWH();

//Initialize Variables-----------------------------------------------|


window.onload=function()
{
				
	commonFunctionsAfterLoad();
	
	var ht_1=document.getElementById('header').clientHeight;
	var ht_2=document.getElementById('home_body').clientHeight;
	var ht_3=document.getElementById('footer_sp').clientHeight;
	var ht_4=document.getElementById('footer').clientHeight;
	
	var ttl_h=(ht_1+ht_2+ht_3+ht_4);
	if(myHeight>ttl_h)
	document.getElementById('extra_spacing').style.height=(myHeight-ttl_h)+'px';
}



window.onresize=function()
{
	
	afterResized();
	
	document.getElementById('extra_spacing').style.height='1px';
	var ht_1=document.getElementById('header').clientHeight;
	var ht_2=document.getElementById('home_body').clientHeight;
	var ht_3=document.getElementById('footer_sp').clientHeight;
	var ht_4=document.getElementById('footer').clientHeight;
	
	var ttl_h=(ht_1+ht_2+ht_3+ht_4);
	if(myHeight>ttl_h)
	document.getElementById('extra_spacing').style.height=(myHeight-ttl_h)+'px';
}





//==========================FOR MENU-========================>

function menuCreate(menuid,wth,hth)
{
	menuColorChange(menuid)
	
	document.getElementById(menuid).style.width=wth+'px';
	$(menuid).addEvents({
		'mouseenter': function(){		
			this.set('tween', {
				duration: 300,
				transition: Fx.Transitions.Bounce.Out // This could have been also 'bounce:out'
			}).tween('height', hth+'px');
		},
		'mouseleave': function(){			
			this.set('tween', {
			duration: 1000,
				transition: Fx.Transitions.Bounce.easeOut
			
			}).tween('height', '20px');
		}
	});
}

function menuColorChange(titleId)
{
	color = '#FFFFFF';
	
	// We are setting the opacity of the element to 0.5 and adding two events
	$(titleId).set('opacity', 0.5).addEvents({
		mouseenter: function(){
			// This morphes the opacity and backgroundColor
			this.morph({				
				'opacity': 1,
				'background-color': '#6699AA',
				'color': color
			});
		},
		mouseleave: function(){
			// Morphes back to the original style
			this.morph({
				opacity: 0.5,
				backgroundColor: color,
				color: '#6699AA'
				
			});
		}
	});
}
//==========================FOR MENU-========================|

function divColorChange(divId,fromcol,tocol)
{
	
	// We are setting the opacity of the element to 0.5 and adding two events
	$(divId).set('opacity', 1).addEvents({
		mouseenter: function(){
			// This morphes the opacity and backgroundColor
			this.morph({			    
				'opacity': 1,
				'background-color': fromcol,
				'color': tocol
			});
		},
		mouseleave: function(){
			// Morphes back to the original style
			this.morph({
				opacity: 1,
				backgroundColor: tocol,
				color: fromcol
			});
		}
	});
}




function expandDiv(divid,fromhth,tohth)
{			
	divColorChange(divid,'#CC6666','#F6F6F6');
	
	$(divid).addEvents({
		'click': function(){
			
			if(this.style.height!=fromhth+'px')
			{								
				this.set('tween', {
					duration: 300,
					transition: Fx.Transitions.Bounce.Out // This could have been also 'bounce:out'
				}).tween('height', fromhth+'px');
				
				
				$(prevDiv).set('tween', {
				duration: 300,
					transition: Fx.Transitions.Bounce.Out				
				}).tween('height', tohth+'px');
				
				prevDiv=divid;/////***
			}
			
		}
		
	});
		
}


function openSearchMenu()
{
	document.getElementById('srcmenu').style.display='block';
}
function closeSearchMenu()
{
	document.getElementById('srcmenu').style.display='none';
}
function menuMouseIn(obj)
{
	obj.style.backgroundColor='#5e93b2';
	obj.style.color='#FFFFFF';
}
function menuMouseOut(obj)
{
	obj.style.backgroundColor='#F6F6F6';
	obj.style.color='#0C364E';
}
function menuClick(num,str)
{	
	document.getElementById('menu_sel_text').innerHTML=str;
	closeSearchMenu();
	document.getElementById('search_text').select();
}




function addtocart(tmplt_id,divname)
{
	addtocartqty(tmplt_id,divname,1);
}


function addtocartqty(tmpltid,divname,qtyn)
{
	getVar='tmplt_id='+tmpltid+'&qty='+qtyn;
	submitForm('','add_to_cart',getVar,base_url+'/cart','');
}




function editTemplate(tmplt_id,divname)
{
	getVar='mc_id='+tmplt_id;
	submitForm(divname,'set_edit_template',getVar,base_url+'/designer/new','');
}

function readCartHeader()
{
	getVar='no';
	getDataAJX('crthdr','read_cart_header',getVar);
}


function submitNletter(msg)
{
	document.getElementById('news_letter_msg').style.display='block';
	nleml=document.getElementById('hnletter').value;
	if(isprEmail(nleml))
	{
		getVar='nl_email='+nleml;
		nletterAJX('news_letter_msg','submit_nletter',getVar);
	}
	else document.getElementById('news_letter_msg').innerHTML=msg;
	
	return false;
}

function nletterAJX(loadtoid,pageName,getVar)
{
	
	if(loadtoid!='')document.getElementById(loadtoid).innerHTML='Loading...';
	
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
			  alert("Your browser does not support AJAX!");
			  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			//alert(xmlHttp.responseText);
			if(loadtoid!='')document.getElementById(loadtoid).innerHTML=xmlHttp.responseText;			
		  }
		}
	
	  xmlHttp.open("GET",base_url+"/site/user/php/pbox/"+pageName+".php?"+getVar,true);
	  xmlHttp.send(null);
}


function getDataAJX(loadtoid,pageName,getVar)
{
	
	if(loadtoid!='')document.getElementById(loadtoid).innerHTML='Loading...';
	
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
			  alert("Your browser does not support AJAX!");
			  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			//alert(xmlHttp.responseText);
			if(loadtoid!='')document.getElementById(loadtoid).innerHTML=xmlHttp.responseText;
			
		  }
		}
	
	  xmlHttp.open("GET",base_url+"/site/user/php/pbox/"+pageName+".php?"+getVar,true);
	  xmlHttp.send(null);
}

function isprEmail(email)
{
 	if(email.length <= 0)
	{
	  return false;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
	return false;
}

