function shopcart(product_id,update,qty,combotype)
{
	document.shopcartForm.product_id.value = product_id;
	document.shopcartForm.shopqty.value = qty;
	document.shopcartForm.combotype.value = combotype;
	if(update == 'remove'){
		document.shopcartForm.submitType.value = "remove";
		document.shopcartForm.submit();
	}else if(update == 'update'){
		document.shopcartForm.submitType.value = "update";
		document.shopcartForm.submit();
	}
}
function showbigimage(cat,img)
 {
   window.open("showbigimage.php?cat="+cat+"&img="+img+" ","_blank","toolbar=no, location=no,directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=645, height=480");
 }

// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) {
              	win.window.focus();
           }
}


function jumpMenu(target,object,restore){
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDoc(formName) {
  var obj;

	if (obj=findObj(formName)!=null)
	{
		findObj(formName).submit();
	} else {
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}

function checkRequired(form, fields)
	{	  
	  for (i = 0; i < fields.length; i++)
	  {
	  
		
			
		if (trim(form[fields[i]].value) == "")
		{		  
				
		  var elem = form[fields[i]];
		  alert(elem.id + " is required" );
		  elem.focus(); 
		  elem.value="";
		  return false;
		}
		else if(form[fields[i]].name == "email")
		{
			if(form.email.value.indexOf('@') == -1 || form.email.value.indexOf('.') == -1 )
			{
				alert("{/literal}{$smarty.const.ERROR_INVALID_EMAIL}{literal}");
				form.email.focus();
				return false;
			}
		}
		else if(form[fields[i]].name == "password")
		{
			var pass = form[fields[i]];
		}
		else if(form[fields[i]].name == "cpassword")
		{
			var cpass = form[fields[i]];
		}
		else if(form[fields[i]].name == "chktc")
			{
				if (!form.chktc.checked)
			{
			alert ("You should agree to Terms & Conditions.") ;
			return false;	
			}	
		}

	  }
	  
	  if(pass.value != cpass.value)
	  {
	  	alert(pass.id+" and "+cpass.id+" fields doesn't match");
		pass.focus();		
		return false;
	  }
	  
	  return true;
	}	

		function fncEnable(form, fields)
		{
		  if(form[fields[0]].checked == true)
		  {
			for (i = 1; i < fields.length; i++)
			{
			  form[fields[i]].disabled = true;
			}
		  }
		  else
		  {
			for (i = 1; i < fields.length; i++)
			{
			  form[fields[i]].disabled = false;
			}
		  }
		}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-500px"
	clearTimeout(timer);
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// ON MOUSE OVER TEMPLATE //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showtrail(imagename,title,width,height){
	i = imagename
	t = title
	w = width
	h = height
	timer = setTimeout("show('"+i+"',t,w,h);",200);
}
function show(imagename,title,width,height){
 
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		width+=30
		height+=55
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse; 

		
		newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Loading template preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		newHTML = newHTML + '<h2 class="title_h2">' + ' '+title + '</h2>'
		
    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0"></div>';
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
			newHTML = newHTML+'';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
	}
}


/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}


////


//alert(FormatNumber("2335.78",2,true,false,','));

function sendVal(Laction)
{
	document.sendSession.action ="index.php?action="+Laction;
	var pageAction = Laction;
	document.getElementById('pageAction').value = pageAction;
	document.sendSession.submit();
}


function sendCartVal(paction,Lact)
{
	document.sendCart.action = 'index.php?action='+paction+'&act='+Lact;
	document.getElementById("cartAction").value = paction;
	document.getElementById("cartAct").value = Lact;
	document.sendCart.submit();
}

function OpenPopup(url)
{
	var swidth = screen.width;
	var sheight = screen.height;
	scleft = ((swidth-700)/2);
	sctop =  ((sheight-510)/2);
	window.open(url,'','width=700,height=510,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=no,top='+sctop+',left='+scleft);	
}

	function __blank(){
		document.searchform.region.selectedIndex = 0;
		document.searchform.bargetype.selectedIndex = 0;
		document.searchform.passenger.selectedIndex = 0;
		document.searchform.price.selectedIndex = 0;
	}
	
	function __blank_hotel(){
		document.searchform.region.selectedIndex = 0;
		document.searchform.bargetype.selectedIndex = 0;
		document.searchform.city.selectedIndex = 0;
		document.searchform.price.selectedIndex = 0;

	}



