/*
Site Develope BY
Author: Avi Zafrir
Date: 29.7.2008
*/
var neigberfind=new Array();
var neigbertitle=new Array();
var prdtraficdefult=new Array();

var prdprices = new Array();

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		window.onload = func;
	else {
		window.onload = function() {
			if (oldonload) oldonload();
			func();
		}
	}
}

function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function checkEmail(str) {
///// function for validating email address
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1){
	    return false
	} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	    return false
	} else 	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	} else  if (str.indexOf(at,(lat+1))!=-1){
	    return false
	} else 	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	   return false
	} else  if (str.indexOf(dot,(lat+2))==-1){
	    return false
	} else if (str.indexOf(" ")!=-1){
	     return false
	} else {
	 	return true
	}
}

function getFlashMovieObject(movieName)
{
	if (document.embeds && document.embeds[movieName])
		return document.embeds[movieName];
	if (window.document[movieName])
		return window.document[movieName];
	if (navigator.appName.indexOf("Microsoft Internet")==1)
		return document.getElementById(movieName);
}

function checkMultipleEmail(emails, split_char) {
	emails_array = emails.split(split_char);
	checkStatus = true;
	for (e in emails_array) {
		if (trim(emails_array[e]) != "" && !checkEmail(trim(emails_array[e])))
			checkStatus =false;
	}
	return checkStatus;
}

function checkML(emailValue)
{
	if(!checkEmail(emailValue))
	{
		alert (_tpl_emailNotValid);
		document.joinML.focus();
		return false;
	} else {
		var url = "xmlJoinML.php?joinML_email="+emailValue+"&eng="+eng;
		var xml = LoadXML(url);
		if(xml != null)
		{
			var message = xml.getElementsByTagName('rsp')[0].firstChild.data;
			alert(message);
			var response = xml.getElementsByTagName('rsp_stat')[0].firstChild.data;
			if (response)
				document.joinML.reset();
			else
				document.joinML.focus();
		}
		return false;
	}
}

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

function LoadHTML(url) {
	var xmlHttp = getHTTPObject();
	xmlHttp.open("GET",url, false);
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState != 4)  { return; }
		var serverResponse = xmlHttp.responseText;
	}
	xmlHttp.send(null);
	return xmlHttp.responseText;
}

function LoadXML(url) {
	var xmlHttp = getHTTPObject();
	xmlHttp.open("GET",url, false);
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState != 4)  { return; }
		var serverResponse = xmlHttp.responseText;
	};
	xmlHttp.send(null);
	return xmlHttp.responseXML.documentElement;
}

function PostXML(url,params) {
	xmlHttp = false;
	// branch for native XMLHttpRequest object
	if( window.XMLHttpRequest && !(window.ActiveXObject) ) {
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e) {
			xmlHttp = false;
		}
		// branch for IE/Windows ActiveX version
	}
	else if(window.ActiveXObject) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xmlHttp = false;
			}
		}
	}

	if (xmlHttp) {
		xmlHttp.open( "POST", url, false );
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		return xmlHttp.responseXML.documentElement;
	}
}

// bulid string with the form values, fobj the form object, valFunc is validate function
function getFormValues(fobj) {
   var str = "";
   var valueArr = null;
   var val = "";
   var cmd = "";

   for(var i = 0;i < fobj.elements.length;i++) {
       switch(fobj.elements[i].type) {
		case "text":
		case "hidden":
		case "textarea":
			str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
		break;

		case "radio":
		case "checkbox":
			if(fobj.elements[i].checked)
				str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
		break;

		case "select-one":
			str += fobj.elements[i].name + "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&";
		break;
       }
   }

   str = str.substr(0,(str.length - 1));
   return str;
}

// validate is got the validate function, if false then skip the validation
function submitAjaxForm(f,url) {
   var str = getFormValues(f);
   xmlReq = postAjaxForm(url ,str);
}

function postAjaxForm(url,str) {
   var doc = null
   if (typeof window.ActiveXObject != 'undefined' ) {
       doc = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else {
       doc = new XMLHttpRequest();
       doc.onload = displayState;
   }

   doc.open( "POST", url, true );
   doc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   doc.send(str);
   return doc.responseXML.documentElement;
}

function showMessage(message, elementID) {
	document.getElementById(elementID).innerText=message;
}

function clearMessage(elementID) {
	document.getElementById(elementID).innerText="";
}

function IsNumeric(sText) {
   var ValidChars = "0123456789.-,()+ ";
   var IsNumber=true;
   var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function trim(strText) {
/// TRIM STRING FUNCTION
    // this will get rid of leading spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);
    // this will get rid of trailing spaces
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
}

function escapeString(sString)
{
// DETECT WHAT TO PUT STRING IN FOR HTML FORM ( ' OR " ) DEPANDING ON STRING CONTENTS
	if (sString.indexOf("'") == -1)
		valSep = "'";
	else
		valSep = '"';
	return valSep+sString+valSep;
}

function replaceSubstring(inputString, fromString, toString) {
 // GOES THROUGH THE INPUTSTRING AND REPLACES EVERY OCCURRENCE OF FROMSTRING WITH TOSTRING
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
}

function popupWin(popUrl, width, height) {
	if (!navigator.appName.indexOf("Microsoft")) width+=20;
	height+=5;
	topVar=((screen.height / 2)-(height/2));
	leftVar=((screen.width / 2)-(width/2));
	window.open(popUrl, "PopUp", "height="+height+", width="+width+", top="+topVar+", left="+leftVar+", scrollbars=yes, status=no, location=no, resize=yes, menubar=no, titlebar=no, toolbar=no");
}

function switchElementDisplay(elementID) {
// SWITCH SELECTED ELEMENT DISPLAY: NONE/INLINE
	if (document.getElementById(elementID).style.display=="none")
		document.getElementById(elementID).style.display="inline";
	else
		document.getElementById(elementID).style.display="none";
}

function formvalid (curForm) {
	if (curForm.fname.value=="") {
		curForm.fname.className="red";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=_alert_firstName;
		curForm.fname.focus();

		return false;
	}
	else {
		curForm.fname.className=" ";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=" ";
	}

	if (curForm.Phone.value=="") {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone_empty;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	if (!IsNumeric(curForm.Phone.value)) {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	if (curForm.Email.value=="") {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_alert_email;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	if (!checkEmail(curForm.Email.value)) {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_tpl_emailNotValid;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	document.getElementById("sendButton").value=_tpl_submitting;
	return true;
}

function framevalid (curForm) {
	if (curForm.fname.value=="") {
		curForm.fname.className="red";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=_alert_firstName;
		curForm.fname.focus();

		return false;
	}
	else {
		curForm.fname.className=" ";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=" ";
	}

	if (curForm.Phone.value=="") {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone_empty;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	if (!IsNumeric(curForm.Phone.value)) {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	if (curForm.Email.value=="") {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_alert_email;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	if (!checkEmail(curForm.Email.value)) {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_tpl_emailNotValid;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	return true;
}

function confirmationvalid(curForm) {
	if (curForm.Email.value=="") {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_alert_email;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	if (!checkEmail(curForm.Email.value)) {
		curForm.Email.className="red";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=_tpl_emailNotValid;
		curForm.Email.focus();

		return false;
	}
	else {
		curForm.Email.className=" ";
		var Emailtextd = document.getElementById("Emailtext");
		Emailtextd.innerHTML=" ";
	}

	if (curForm.fname.value=="") {
		curForm.fname.className="red";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=_alert_firstName;
		curForm.fname.focus();
		return false;
	}
	else {
		curForm.fname.className=" ";
		var fnametextd = document.getElementById("fnametext");
		fnametextd.innerHTML=" ";
	}

	if (curForm.lname.value=="") {
		curForm.lname.className="red";
		var lnametextd = document.getElementById("lnametext");
		lnametextd.innerHTML=_alert_lastName;
		curForm.lname.focus();

		return false;
	}
	else {
		curForm.lname.className=" ";
		var lnametextd = document.getElementById("lnametext");
		lnametextd.innerHTML=" ";
	}

	if (curForm.street.value=="") {
		curForm.street.className="red";
		var addresstextd = document.getElementById("streettext");
		addresstextd.innerHTML=_alert_street;
		curForm.street.focus();

		return false;
	}
	else {
		curForm.street.className=" ";
		var addresstextd = document.getElementById("streettext");
		addresstextd.innerHTML=" ";
	}

	if (curForm.city.value=="") {
		curForm.city.className="shortinput red";
		var addresstextd = document.getElementById("citytext");
		addresstextd.innerHTML=_alert_city;
		curForm.city.focus();

		return false;
	}
	else {
		curForm.city.className="shortinput";
		var addresstextd = document.getElementById("citytext");
		addresstextd.innerHTML=" ";
	}

	if (curForm.Phone.value=="") {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone_empty;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	if (!IsNumeric(curForm.Phone.value)) {
		curForm.Phone.className="red";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=_alert_phone;
		curForm.Phone.focus();

		return false;
	}
	else {
		curForm.Phone.className=" ";
		var Phonetextd = document.getElementById("Phonetext");
		Phonetextd.innerHTML=" ";
	}

	return true;
}

function paymentValid(curForm) {
	if (curForm.fname_shp.value=="") {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.fname_shp.className="red";
		var fnametextd = document.getElementById("fnametextshp");
		fnametextd.innerHTML=_alert_firstName;
		curForm.fname_shp.focus();

		return false;
	}
	else {
		curForm.fname_shp.className=" ";
		var fnametextd = document.getElementById("fnametextshp");
		fnametextd.innerHTML=" ";
	}

	if (curForm.lname_shp.value=="") {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.lname_shp.className="red";
		var lnametextd = document.getElementById("lnametextshp");
		lnametextd.innerHTML=_alert_lastName;
		curForm.lname_shp.focus();

		return false;
	}
	else {
		curForm.lname_shp.className=" ";
		var lnametextd = document.getElementById("lnametextshp");
		lnametextd.innerHTML=" ";
	}

	if (curForm.street_shp.value=="") {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.street_shp.className="red";
		var addresstextd = document.getElementById("streettextshp");
		addresstextd.innerHTML=_alert_street;
		curForm.street_shp.focus();

		return false;
	}
	else {
		curForm.street_shp.className=" ";
		var addresstextd = document.getElementById("streettextshp");
		addresstextd.innerHTML=" ";
	}

	if (curForm.city_shp.value=="") {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.city_shp.className="shortinput red";
		var addresstextd = document.getElementById("citytextshp");
		addresstextd.innerHTML=_alert_city;
		curForm.city_shp.focus();

		return false;
	}
	else {
		curForm.city_shp.className="shortinput";
		var addresstextd = document.getElementById("citytextshp");
		addresstextd.innerHTML=" ";
	}

	if (curForm.Phone_shp.value=="") {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.Phone_shp.className="red";
		var Phonetextd = document.getElementById("Phonetextshp");
		Phonetextd.innerHTML=_alert_phone_empty;
		curForm.Phone_shp.focus();

		return false;
	}
	else {
		curForm.Phone_shp.className=" ";
		var Phonetextd = document.getElementById("Phonetextshp");
		Phonetextd.innerHTML=" ";
	}

	if (!IsNumeric(curForm.Phone_shp.value)) {
		$("#billTable").show();
		$("#billingcheckbox").attr("checked",false);
		curForm.Phone_shp.className="red";
		var Phonetextd = document.getElementById("Phonetextshp");
		Phonetextd.innerHTML=_alert_phone;
		curForm.Phone_shp.focus();
		return false;
	}
	else {
		curForm.Phone_shp.className=" ";
		var Phonetextd = document.getElementById("Phonetextshp");
		Phonetextd.innerHTML=" ";
	}

	//netcommerance in creditCardFix.js script
	if( !checkCreditCard() ) {
		return false;
	}

	if (curForm.CC_cvc.value=="") {
		alert(_CC_cvc_empty);
		curForm.CC_cvc.focus();
		return false;
	}

	if(curForm.termsapp.checked == false) {
		alert(_terms_approve);
		return false;
	}

	return true;
	/*if (confirm(_confirm_sendForm))
	{
		return true;
	}
	else
		return false;*/
}

/*
cSlider - class uses script.acoulo.us to make a transition effect on price
Author: Liran Oz
Date: 26.5.2008
*/
function cSlider(_price, _text, _loading, _priceDelta) {
	var price = _price;
	var text = _text;
	var loading = _loading;
	var priceDelta = (_priceDelta) ? _priceDelta : 50;
	var timeOut = 20;
	var transSpeed = 0.5;
	var priceObj = document.getElementById(_price);
	var textObj = document.getElementById(_text);
	var loadingObj = document.getElementById(loading);
	var lastUpdated = null;
	var defualtLoading = 'images/loading_trans.gif';

	var curItem = 0;
	var prices = new Array();
	var captions = new Array();
	var cycling = false;
	var firstDisplay = true;

	if (!priceObj || !textObj)			//must exist!
		return null;

	//set the price object to -delta top position (relative)
	setPriceOpacity(0);
	priceObj.style.position = "relative";
	priceObj.style.top = '-' + priceDelta + 'px';

	//make parent overflow hidden
	priceObj.parentNode.style.overflow = "hidden";

	this.addPrice = function(newPrice, newCaption)
	{
		if (curItem < prices.length-1) {		//short update occured, And not cycling last one
			prices[prices.length-1] = newPrice;
			captions[captions.length-1] = newCaption;
		}
		else {
			prices[prices.length] = newPrice;
			captions[captions.length] = newCaption;
		}

		if (!cycling) {
			cycling = true;
			if (firstDisplay) {
				showPrice();
				firstDisplay = false;

			}
			else
				hidePrice();
		}
	}

	function showPrice() {
		//set price text
		priceObj.innerHTML = prices[curItem];
		textObj.innerHTML = captions[curItem];

		//initiate script.acoulo.us parallel effect
		new Effect.Parallel([
			  new Effect.Move(price, { sync: true, x: 0, y: priceDelta, mode: 'relative' }),
			  new Effect.Opacity(price, { sync: true, from: 0, to: 1 })
			  //new Effect.Scale(text, 100, {scaleFrom: 0, scaleMode: { originalHeight: 10, originalWidth: 250, mode: 'absolute' } })

			], {
			  duration: transSpeed,
			  delay: 0.5,
		      afterFinish: function(effect) {
		        	priceObj.style.top = 0;
		        	priceObj.style.left = 0;
		        	//hide loading background
		        	loadingObj.style.backgroundImage = '';

		        	//show text
		        	textObj.style.display = "block";
		        	//is there a new price in queue?
		        	curItem++;
		        	if (curItem < prices.length) {
		        		//hide this one
		        		hidePrice();
		        	}
		        	else {
		        		//clear array
						prices = new Array();
						captions = new Array();
						curItem = 0;
						cycling = false;
		        	}
		        }}
		);
	}

	function hidePrice() {
		new Effect.Parallel([
			  new Effect.Move(price, { sync: true, x: 0, y: priceDelta, mode: 'relative' }),
			  new Effect.Opacity(price, { sync: true, from: 1, to: 0 })
			], {
			  duration: transSpeed,
			  delay: 0.5,
		      afterFinish: function(effect) {
		        	priceObj.style.top = '-' + priceDelta + 'px';		//back to original position
		        	priceObj.style.left = 0;
		        	//hide text
					textObj.style.display = "none";
		        	//show loading background
		        	loadingObj.style.backgroundImage = 'url('+defualtLoading+')';

		        	if (curItem < prices.length) {		//show again?
		        		showPrice();
		        	}
		        }}
		);
	}

	//style properties from http://snipplr.com/view/707/setopacity/
	function setPriceOpacity(op) {
		setStyleById(price, "filter", "alpha(opacity="+op+")");
		setStyleById(price, "opacity", op/100);
		setStyleById(price, "-moz-opacity", op/100);
	}
}

function saTest()
{
	new Effect.Parallel([
		new Effect.Move('actualprice', { sync: true, x: 0, y: 30, mode: 'relative' }),
		new Effect.Opacity('actualprice', { sync: true, from: 0, to: 1 })
	], {
		duration: 0.8,
		delay: 0.5,
		afterFinish: function(effect) {
			var obj = document.getElementById('actualprice')
			obj.style.top = "-30px";
			obj.style.left = 0;
		}}
	);
}

function nextcategoryprice()
{
	var htmlp = '';
	var curprice = document.getElementById("actualprice");	//div of price

	var cpus=document.getElementById("prd_cpu");
	var oss=document.getElementById("prd_os");
	var rams=document.getElementById("prd_ram");
	var storage=document.getElementById("prd_storage");
	var conpanel=document.getElementById("prd_conpanel");
	var traffic=document.getElementById("prd_traffic");
	var ips=document.getElementById("prd_ips");
	var datacenter=document.getElementById("prd_datacenter");

	var dailybck=document.getElementById("dailybck");
	var firewallo=document.getElementById("firewall");
	var manhosting=document.getElementById("manhosting");
	var nextstorage=neigberfind[storage.value];
	var fullprice=prdprices[cpus.value]+prdprices[oss.value]+prdprices[rams.value]+prdprices[nextstorage]+prdprices[conpanel.value]+prdprices[traffic.value]+prdprices[ips.value]+prdprices[datacenter.value];

	if(dailybck.checked) {
		fullprice=fullprice+(prdprices[nextstorage]/2);
	}

	if(firewallo.checked) {
		fullprice=fullprice+firewallpr;
	}

	if(manhosting.checked) {
		fullprice=fullprice+manhostpr;
	}

	var rofullprice = (Math.round(fullprice * 100) / 100);

	if(ratecurancy==1) {
		var catPrice  = "<span class='get'>"+seclinehp+" <a href='javascript:void(0)' onclick='changestorge()' class='quantity'>"+neigbertitle[storage.value]+"</a> "+seclinehp1+" "+currency_USA+""+rofullprice+"<span class=numberMonth>"+permonth+"</span></span>";
	}
	else {
		var convertedprice=rofullprice*ratecurancy;
		rofullprice = (Math.round(convertedprice * 100) / 100);
		if(ratecurancy==ratetoeuro) {
			var coin=currency_EU;
		}
		else {
			var coin=currency_ISR;
		}
		var catPrice  = "<span class='get'>"+seclinehp+" <a href='javascript:void(0)' onclick='changestorge()' class='quantity'>"+neigbertitle[storage.value]+"</a> "+seclinehp1+" "+coin+""+rofullprice+"<span class=numberMonth>"+permonth+"</span></span>";
	}

	return catPrice;
}

function changecoin() {
	if(ratecurancy==1) {
		ratecurancy=ratetoeuro;
	}
	else if(ratecurancy==ratetoeuro) {
		ratecurancy=ratetosekel;
	}
	else {
		ratecurancy=1;
	}
	calcprice();
}

function changestorge() {
	var storage=document.getElementById("prd_storage");
	var nextstorage=neigberfind[storage.value];
	storage.value=nextstorage;
	calcprice();
}

function additemtocart() {
	var htmlp = '';
	var curprice = document.getElementById("actualprice");	//div of price

	var cpus=document.getElementById("prd_cpu");
	var oss=document.getElementById("prd_os");
	var rams=document.getElementById("prd_ram");
	var storage=document.getElementById("prd_storage");
	var conpanel=document.getElementById("prd_conpanel");
	var traffic=document.getElementById("prd_traffic");
	var ips=document.getElementById("prd_ips");
	var datacenter=document.getElementById("prd_datacenter");

	var dailybck=document.getElementById("dailybck");
	var firewallo=document.getElementById("firewall");
	var manhosting=document.getElementById("manhosting");

	var fullprice=prdprices[cpus.value]+prdprices[oss.value]+prdprices[rams.value]+prdprices[storage.value]+prdprices[conpanel.value]+prdprices[traffic.value]+prdprices[ips.value]+prdprices[datacenter.value];

	if(dailybck.checked) {
		fullprice=fullprice+(prdprices[storage.value]/2);
	}

	if(firewallo.checked) {
		fullprice=fullprice+firewallpr;
	}

	if(manhosting.checked) {
		fullprice=fullprice+manhostpr;
	}

	var rofullprice = (Math.round(fullprice * 100) / 100);

	var url = "cart_functions.php?fullp="+rofullprice+"&cpus="+cpus.value+"&oss="+oss.value+"&rams="+rams.value+"&storage="+storage.value+"&conpanel="+conpanel.value+"&traffic="+traffic.value+"&ips="+ips.value+"&datacenter="+datacenter.value+"&dailybck="+dailybck.checked+"&firewallo="+firewallo.checked+"&manhosting="+manhosting.checked;
	var xml = LoadHTML(url);
	if(xml == null) {
		alert(_itemadderror);
	}
	window.location.href="ShoppingCart.php";
	return false;
}

function addpacktocart(cpus,oss,rams,storage,conpanel,traffic,ips,datacenter,dailybck,firewallo,manhosting,coupon)
{
	var htmlp = '';

	//LOAD PRICE CHANGES FOR CENTER AND EVAL THEM :)
	var url = "ajax_functions.php?action=changepricelist&centerid="+datacenter;
	var htmlt = LoadHTML(url);
	if(htmlt)
		eval(htmlt);

	var fullprice=prdprices[cpus]+prdprices[oss]+prdprices[rams]+prdprices[storage]+prdprices[conpanel]+prdprices[traffic]+prdprices[ips]+prdprices[datacenter];
	if(dailybck) {
		fullprice=fullprice+(prdprices[storage]/2);
	}

	if(firewallo) {
		fullprice=fullprice+firewallpr;
	}

	if(manhosting) {
		fullprice=fullprice+manhostpr;
	}

	var rofullprice = (Math.round(fullprice * 100) / 100);

	var url = "cart_functions.php?fullp="+rofullprice+"&cpus="+cpus+"&oss="+oss+"&rams="+rams+"&storage="+storage+"&conpanel="+conpanel+"&traffic="+traffic+"&ips="+ips+"&datacenter="+datacenter+"&dailybck="+dailybck+"&firewallo="+firewallo+"&manhosting="+manhosting+"&copun="+coupon;
	var xml = LoadHTML(url);
	if(xml == null) {
		alert(_itemadderror);
	}
	window.location.href="ShoppingCart.php";
	return false;
}

function clearcart() {
	if (confirm(_confirm_delcart)) {
		var url = "ajax_functions.php?action=clearcart";
		var xml = LoadHTML(url);
		if(xml == null) {
			alert(_cartdelerror);
		}
		 window.location.reload( true );
		return true;
	}
	else
		return false;
}

function removefromcart(prdid) {
	if (confirm(_confirm_removeline)) {
		var url = "ajax_functions.php?action=deline&prdid="+prdid;
		var xml = LoadHTML(url);
		if(xml != null) {
			window.location.reload( true );
		}
	}
	return false;
}

function changelinefromcart(prdid,link) {
	var url = "ajax_functions.php?action=deline&prdid="+prdid;
	var xml = LoadHTML(url);
	if(xml != null) {
		window.location.href=link;
	}

	return false;
}

function fillbillinfo() {
	curForm=document.getElementById("confirmform");
	curForm.fname_shp.value= curForm.fname.value;
	curForm.lname_shp.value= curForm.lname.value;
	curForm.street_shp.value= curForm.street.value;
	curForm.city_shp.value= curForm.city.value;
	curForm.country_shp.value= curForm.country.value;
	curForm.Phone_shp.value=curForm.Phone.value;
	curForm.mobile_shp.value=curForm.mobile.value;
	curForm.fax_shp.value=curForm.fax.value;
	if(curForm.postal.value != "") {
		curForm.postal_shp.value= curForm.postal.value;
	}

	if(curForm.state.value != "") {
		curForm.state_shp.value= curForm.state.value;
	}
}

function changeandcalc(osid) {
	var rams=document.getElementById("prd_ram");
	var storage=document.getElementById("prd_storage");
	//change storage
	var storagesd = document.getElementById("prd_storagediv");
	var url = "ajax_functions.php?action=changestorage&osid="+osid.value+"&curstorage="+storage.value;
	var xml = LoadHTML(url);
	if( xml != null && xml != "" ) {
		storagesd.innerHTML=xml;
	}
	//change memory
	var ramd = document.getElementById("prd_ramdiv");
	var url = "ajax_functions.php?action=changememory&osid="+osid.value+"&curmemory="+rams.value;
	var xml = LoadHTML(url);
	if( xml != null && xml != "" ) {
		ramd.innerHTML=xml;
	}

	calcprice();

	return false;
}

function changeLang(cursel) {
	if(cursel.value=="eng") window.location.href="http://www.clubvps.com/";
	if(cursel.value=="heb") window.location.href="http://il.clubvps.com/";
	if(cursel.value=="dut") window.location.href="http://nl.clubvps.com/";
}

function chkncupon(curForm) {
	if (curForm.cuponcode.value=="") {
		alert(_cupon_alert);
		curForm.cuponcode.focus();

		return false;
	}
	return true;
}

function changetrafficandcalc(centerid) {
	var trafficsel=document.getElementById("traffic_allowed");
	/*trafficsel.value=prdtraficdefult[centerid];*/

	//LOAD PRICE CHANGES FOR CENTER AND EVAL THEM :)
	var url = "ajax_functions.php?action=getallowedtraffic&centerid="+centerid+"&deftraffic="+prdtraficdefult[centerid];
	var htmltraffic = LoadHTML(url);
	if(htmltraffic)
		trafficsel.innerHTML=htmltraffic;

	//LOAD PRICE CHANGES FOR CENTER AND EVAL THEM :)
	var url = "ajax_functions.php?action=changepricelist&centerid="+centerid;
	var htmlt = LoadHTML(url);
	if(htmlt)
		eval(htmlt);

	calcprice();

	return false;
}

function changepriceandcalc(centerid) {
	//LOAD PRICE CHANGES FOR CENTER AND EVAL THEM :)
	var url = "ajax_functions.php?action=changepricelist&centerid="+centerid;
	var htmlt = LoadHTML(url);
	if(htmlt)
		eval(htmlt);

	calcprice(); 

	return false;
}

function showcopun(textstart,textbtn) {
	var divid=document.getElementById("coupndiv");
	divid.innerHTML=textstart+"<input type='text' name='cuponcode' /> <input type='submit' value='"+textbtn+"' />";
}

function showBillForm() {
	$("#billTable").slideToggle("fast");
}

var slider = null;
var show_price = true; // use us when user choose obly purpose -> we dont want to ' fadeIn ' the #price_title div
function calcprice() {
	var htmlp = '';
	var curprice = document.getElementById("actualprice");	//div of price

	var cpus=document.getElementById("prd_cpu");
	var oss=document.getElementById("prd_os");
	var rams=document.getElementById("prd_ram");
	var storage=document.getElementById("prd_storage");
	var conpanel=document.getElementById("prd_conpanel");
	var traffic=document.getElementById("prd_traffic");
	var ips=document.getElementById("prd_ips");
	var datacenter=document.getElementById("prd_datacenter");

	var dailybck=document.getElementById("dailybck");
	var firewallo=document.getElementById("firewall");
	var manhosting=document.getElementById("manhosting");

	var fullprice=prdprices[cpus.value]+prdprices[oss.value]+prdprices[rams.value]+prdprices[storage.value]+prdprices[conpanel.value]+prdprices[traffic.value]+prdprices[ips.value]+prdprices[datacenter.value];

	if(dailybck.checked) {
		fullprice=fullprice+(prdprices[storage.value]/2);
	}

	if(firewallo.checked) {
		fullprice=fullprice+firewallpr;
	}

	if(manhosting.checked) {
		fullprice=fullprice+manhostpr;
	}

	var rofullprice = (Math.round(fullprice * 100) / 100);
	if(ratecurancy==1) {
		htmlp="<span class='number'><a href='javascript:void(0)' onclick='changecoin()' class='money'>"+currency_USA+"</a>"+rofullprice+"<span class=numberMonth>"+permonth+"</span></span>";
	}
	else {
		var convertedprice=rofullprice*ratecurancy;
		rofullprice = (Math.round(convertedprice * 100) / 100);
		if(ratecurancy==ratetoeuro) {
			var coin=currency_EU;
		}
		else {
			var coin=currency_ISR;
		}
		htmlp="<span class='number'><a href='javascript:void(0)' onclick='changecoin()' class='money'>"+coin+"</a>"+(rofullprice)+"<span class=numberMonth>"+permonth+"</span></span>";
	}

	var priceDesc = nextcategoryprice();

	var defualtLoading = 'images/loading_trans.gif';
	$("#price_loading").css({'overflow':'hidden','position':'relative'});
	$("#actualprice").css({'position':'absolute','top':'0px','left':'0px','opacity':'0.999999'});

	$("#actualprice").animate({'opacity': '0', top: '+=50'},"slow",function(){
		$(this).css({'top':'-50px'}).html(htmlp).animate({'opacity':'0.99999', top:'0'},"slow");
	});

	$("#price_title").css({'position':'absolute','top':'50px','opacity':'0.99999'});
	$("#price_title").fadeOut("slow",function(){
		$("#price_loading").css({'background-image':'url('+defualtLoading+')'});
		if( show_price == true ) {
			$("#adv_choose").hide();
			$("#actualprice").show();
			$(this).html(priceDesc).delay("1000").fadeIn("slow",function(){
				//$("#price_loading").removeAttr("style");
				$("#price_loading").css({'background-image':''});
			});
		}
		else {
			$("#price_loading").css({'background-image':''});
			show_price = true;
		}
	});

	return false;
}

function change_size_list(purpose_id) {
//	shakeMainForm();
	fly_out();
	$("form#main_config").find(":checkbox").attr('checked', false);
	$("form#main_config select").each(function(){
		$(this).find("option").removeAttr("selected");
	    $(this).find("option").each(function(t,sel){
	    	if(t==0) {
	    		$(sel).attr({"selected":"selected"});
	    	}
        });
	});

	show_price = false;
	calcprice();

	var resHTML = "";
//	if( purpose_id == "" ) return;
	if( purpose_id != "" ) {
		var size = purpose_list_data[purpose_id];
		resHTML += "<option value='0'>"+choose_size+"</option>";
		$.each(size.sizes, function(i, item) {
			var currsize = size_list_data[item];
			if( currsize.title != "" ) {
				resHTML += "<option value='"+currsize.id+"'>"+currsize.title+"</option>";
			}
		});
	}

	$("#advisor_size").html(resHTML);
	$(".advisor_list").html("");
	
	$("#actualprice,#price_title").hide();
	$("#adv_choose").show();
}

function update_configuration(curr_size_id) {
	$("#adv_desc").hide();
	$(".advisor_list").hide();
	$(".more").hide();
	if( show_price == false ) {
		shakeMainForm();
	}
	else {
		fly_in();
	}
	show_price = true;

	if( curr_size_id == 0 ) return;

	$("#adv_choose").hide();
	$("#actualprice,#price_title").show();

//	$(".adv_motion").css({'width': '20px', 'height':'20px', _align_mir: '10px', 'opacity':'0.99'}).show();
//	$(".adv_motion").animate({'width': '570px', 'height':'300px', _align_mir: '+=330', 'opacity':'0.5'},"slow",function(){
//		$(this).hide();
//	});

	var size = size_list_data[curr_size_id];
//	console.log("current size = ");
//	console.log(size);

	$(".advisor_list").html(size.desc_list);
	$("#prd_cpu").val(size.cpu);
	$("#prd_os").val(size.os);
	$("#prd_ram").val(size.ram);
	$("#prd_storage").val(size.storage);
	$("#prd_conpanel").val(size.conpanel);
	$("#prd_traffic").val(size.traffic);
	$("#prd_ips").val(size.ips);
	$("#prd_datacenter").val(size.datacenter);

//	var sizeSelectNames = ['cpu','os','ram','storage','conpanel','traffic','ips','datacenter'];
//	$(sizeSelectNames).each(function(i,o){
////		console.log("obj = "+o);
//		var tempVal = ( size.o != "" && size.o != null && size.o != "null" ) ? size.o : $("#prd_"+o+" option:first").val();
//		console.log("tempVal = "+tempVal);
////		$("#prd_"+o).val(tempVal);
//	});

// we need to check if size values are not empty ('' || null) for selecting the chosen options
// in IE9 empty val (i.e: val(null) ) => IE9 create new select option with empty val and make an error on calculator 
//	$("#prd_cpu").val(  ( size.cpu != "" && size.cpu != null && size.cpu != "null" ) ? size.cpu : $("#prd_cpu option:first").val() );
//	$("#prd_os").val(  ( size.os != "" && size.os != null && size.os != "null" ) ? size.os : $("#prd_os option:first").val() );
//	$("#prd_ram").val(  ( size.ram != "" && size.ram != null && size.ram != "null" ) ? size.ram : $("#prd_ram option:first").val() );
//	$("#prd_storage").val(  ( size.storage != "" && size.storage != null && size.storage != "null" ) ? size.storage : $("#prd_storage option:first").val() );
//	$("#prd_conpanel").val(  ( size.conpanel != "" && size.conpanel != null && size.conpanel != "null" ) ? size.conpanel : $("#prd_conpanel option:first").val() );
//	$("#prd_traffic").val(  ( size.traffic != "" && size.traffic != null && size.traffic != "null" ) ? size.traffic : $("#prd_traffic option:first").val() );
//	$("#prd_ips").val(  ( size.ips != "" && size.ips != null && size.ips != "null" ) ? size.ips : $("#prd_ips option:first").val() );
//	$("#prd_datacenter").val(  ( size.datacenter != "" && size.datacenter != null && size.datacenter != "null" ) ? size.datacenter : $("#prd_datacenter option:first").val() );

	$("#dailybck").attr('checked', (size.backup == "Y") ? true : false );
	$("#firewall").attr('checked', (size.firewall == "Y") ? true : false );
	$("#manhosting").attr('checked', (size.managed == "Y") ? true : false );

	$("#adv_desc,.advisor_list,.more").show();
	calcprice();
}

function resetConfigurator() {
	var disp = $("#adv_choose_new").css("display");

	$("form#main_config").find(":checkbox").attr('checked', false);
	$("form#main_config select").each(function(){
		$(this).find("option").removeAttr("selected");
		$(this).find("option").each(function(t,sel){
			if(t==0) {
				$(sel).attr({"selected":"selected"});
			}
		});
	});
	$("#advisor_purpose").each(function(){
		$(this).find("option").removeAttr("selected");
		$(this).find("option").each(function(t,sel){
			if(t==0) {
				$(sel).attr({"selected":"selected"});
			}
		});
	});
	$("#advisor_size").html("");

	$("#adv_desc,.advisor_list,.more,#adv_choose").hide();
	$("#actualprice,#price_title").show();
//	if( disp == "block") { fly_in(); }
	resetStorageAndMemory();
	shakeMainForm();

	show_price = true;
	calcprice();

//	var t = setTimeout('resetStorageAndMemory()',1500);
}

function resetStorageAndMemory() {
	var osVal = $("#prd_os option:first").val();

	// change storage
	var url = "ajax_functions.php?action=changestorage&osid="+osVal;
	runJqueryAjax(url,"","#prd_storagediv");

	// change memory
	var url = "ajax_functions.php?action=changememory&osid="+osVal;
	runJqueryAjax(url,"","#prd_ramdiv");
}

function shakeMainForm() {
	var ww = $(window).width();
//	var w = $("#main_config").width();
	if( ww < 920 ) ww = 920; 
	if( lang == "heb" ) { // lang defined in headerHead
		$("#main_config").animate({ 'right': '-='+ww},800,"swing",function(){
//			$(this).css({'right':ww+'px'}).delay("300").animate({'right':'0px'},400,"swing"); // easeOutElastic |  easeOutQuad
			$("#adv_choose_new").fadeOut("slow");
			$(this).css({'right':ww+'px'}).animate({'right':'0px'},400,"swing");
		});
	}
	else {
		$("#main_config").animate({ 'left': '-='+ww},800,"swing",function(){
			$("#adv_choose_new").fadeOut("slow");
			$(this).css({'left':ww+'px'}).animate({'left':'0px'},400,"swing");
		});
	}
}

function fly_out() {
	var ww = $(window).width();
//	var w = $("#main_config").width();
	if( ww < 920 ) ww = 920; 
	if( lang == "heb" ) {
		$("#main_config").animate({ 'right': '-='+ww},800,"swing",function(){
			$("#adv_choose_new").fadeIn("slow");
		});
	}
	else {
		$("#main_config").animate({ 'left': '-='+ww},800,"swing",function(){
			$("#adv_choose_new").fadeIn("slow");
		});
	}
}

function fly_in() {
	var ww = $(window).width();
//	var w = $("#main_config").width();
	if( ww < 920 ) ww = 920; 
	if( lang == "heb" ) {
		$("#adv_choose_new").fadeOut("slow",function(){
			$("#main_config").css({'right':ww+'px'}).animate({'right':'0px'},400,"swing");	
		});
	}
	else {
		$("#adv_choose_new").fadeOut("slow",function(){
			$("#main_config").css({'left':ww+'px'}).animate({'left':'0px'},400,"swing"); // easeOutElastic |  easeOutQuad
		});
	}
}

function openPPFrame() {
	$.prettyPhoto.open("club_frame.php?iframe=true&amp;width=560&amp;height=480");
}

function runJqueryAjax(url,params,updateElement) {
	var j_ajax = $.ajax({
		type: "POST",
		async: false,
		url: url,
		dataType: "text",
		data: params,
		success: function(htmlResponse){
			if( updateElement != null) {
				$(updateElement).html(htmlResponse);
			}
			else {
				return htmlResponse;
			}
		}
	});
}

var ajax_url = "club_ajax.php";
function show_cat_prd(type,sort,current) {
	url = ajax_url + "?action=showCat";
	params =  "&type="+type+"&sort="+sort+"&current="+current;
	updateElement = "#"+type;
	runJqueryAjax(url,params,updateElement);
}

// memory - storage
function show_ms(type,current) {
	url = ajax_url + "?action=showMS";
	params =  "&type="+type+"&current="+current;
	updateElement = "#"+type;
	runJqueryAjax(url,params,updateElement);
}

// ---------------------------------------------------------------------------------------------
// content.js
// ---------------------------------------------------------------------------------------------
var frame_opened = false;
var frame_window_id = 'frame_window';
var frame_id = 'club_frame';
var frame_location = 'club_frame.php'
var frame_title = 'frame_title';
var fader = null;
var fader_id = 'page';
var fader_iframe = 'iframe_page';
var youtube_id = 'youtube_container';

var iframe_history = new Array();

function number_format(num) {
	var str = '' + num;		//no it's a string
	//is it real number?
	var real = false;
	var i;
	for (i=0; i<str.length; i++) {
		if (str.charAt(i) == '.') {
			real = i;
			break;
		}
	}

	var work_str = '';
	if (real === false)
		work_str = str;
	else
		work_str = str.substring(0, real);

	//group by 3's
	var temp_string = '';
	var j=0;
	for (i=work_str.length-1; i >= 0; i--) {
		if (j == 3) {
			j = 0;
			temp_string += ',';
		}

		temp_string += work_str.charAt(i);
		j++;
	}
	//reverse back
	var final_string = '';
	for (i=temp_string.length-1; i>=0; i--)
		final_string += temp_string.charAt(i);
	if (real != false)
		final_string += str.substring(real);
	return final_string;
}

function buildIframeNavigation() {
	//build as innerHTML (this is the fastest method)
	var ihtml;
	ihtml = '<a href="javascript:closeFrame();" class="iframe_align_mir">'+_close_text+'</a>';
	var len = iframe_history.length;
	if (len > 1) {
		ihtml += '<a href="javascript:backFrame(\''+iframe_history[len-2][0]+'\', \''+iframe_history[len-2][1]+'\');" class="iframe_align">'+_back_text+'</a>';
	}
	return ihtml;
}

function addHistoryItem(page, oid) {
	len = iframe_history.length;
	iframe_history[len] = new Array();
	iframe_history[len][0] = page;
	iframe_history[len][1] = oid;
}

function clearHistory() {
	iframe_history = new Array();
}

function getPositionX() {
	return ((document.body.clientWidth-560)/2) +"px";
}

function getPositionY() {
	var scroll = getPageScroll();
	return 100 + scroll[1] + "px";
}

var page;
var oid;

function openFrame() {
	fader = new pageMask(20, 200, fader_id, openRealFrame);
	fader.fadeIn();
}

function backFrame(_page, _oid) {
	page = _page;
	oid = _oid;
	//remove last history item
	var len = iframe_history.length;
	iframe_history[len-1] = null;
	iframe_history.length--;
	if (fader == null) {
		fader = new pageMask(20, 200, fader_id, openRealFrame);
	}
	fader.fadeIn();
}

function openTransactionImage() {
	if (fader == null) {
		fader = new pageMask(20, 200, fader_id, showTransactionImage);
	}
	fader.fadeIn();
}

function showTransactionImage() {
	if (fader == null)
		return;

	var scroll = getPageScroll();

	var par = (fader.getMaskObject());
	par = par.parentNode;
	var img = document.createElement('img');
	img.src = _order_submit;
	img.style.left = ((document.body.clientWidth-178)/2) +"px";
	img.style.top = (scroll[1] + 250) + "px";
	img.style.position = 'fixed';
	img.style.zIndex = "10000";
	par.appendChild(img);
}

var tframe = null;
function openRealFrame() { //(page, oid)
	var frame = document.getElementById(frame_id);

	if (frame_opened) {
		frame.src = frame_location;
		//frames['mano_frame'].location.href =  frame_location + "?page="+page+"&oid="+oid;
		return;
	}

	frame_opened = true;
	var frame_window = document.getElementById(frame_window_id);
	frame.src = frame_location + "?page="+page+"&oid="+oid;
	frame_window.style.left = getPositionX();
	frame_window.style.top = getPositionY();
	frame_window.style.display = "block";
}

function closeFrame() {
	//clearHistory();
	var frame_window = document.getElementById(frame_window_id);
	var frame = document.getElementById(frame_id);
	frame_window.style.display = "none";
	frame.src = "";
	//setFrameTitle('');
	frame_opened = false;

	if (fader == null) {
		return;
	}
	fader.fadeOut();
}

function setFrameTitle(ttl) {
	//document.getElementById(frame_title).innerHTML = ttl;
	return;
}

/*-------------------------------------
page masking object
Liran Oz - 2008
--------------------------------------*/
function pageMask(_opacity, _speed, _container, _callback) {
	var cur_opacity = 0;
	var speed = _speed;
	var step = 10;
	var tar_opacity = _opacity;
	var container_id = _container;
	var mask_obj = null;
	var width;
	var height;
	var cycle_flag = false;
	var interval = null;
	var wait = 30;
	var callback = _callback;
	var select_box = null;
	var objects = null;
	var embeds = null;
	var done_fading = false;
	var inner_working = false;
	var background_color = 'black';

	function setOpacity(opc) {
		mask_obj.style.opacity = opc/100;
		mask_obj.style.filter = 'alpha(opacity=' + opc + ')';
	}

	function createObj() {
		//create new element
		var sz = getPageSize();		//Thank you lightbox
		var cnt = document.getElementById(_container);
		if (!cnt) {
			return false;
		}

		mask_obj = document.createElement('div');
		mask_obj.style.width = sz[2] + "px";
		mask_obj.style.height = sz[1] + "px";
		mask_obj.style.position = "absolute";
		mask_obj.style.left = "0px";
		mask_obj.style.top = "0px";
		mask_obj.style.zIndex = 100;
		mask_obj.style.backgroundColor = background_color;

		cnt.appendChild(mask_obj);
	}

	function removeObj() {
		//create new element
		var sz = getPageSize();		//Thank you lightbox
		var cnt = document.getElementById(container_id);
		if (!cnt) {
			return false;
		}
		cnt.removeChild(mask_obj);
		mask_obj = null;
	}

	this.getMaskObject = function() {
		return mask_obj;
	}

	this.setBackgroundColor = function(col) {
		background_color = col;
	}

	function cycleOpacity() {
		if (mask_obj == null) {
			createObj();
			setOpacity(cur_opacity);
		}

		done_fading = false;
		cur_opacity += step;
		if (cur_opacity >= tar_opacity) {		//no more cyclig
			inner_working = true;
			cur_opacity = tar_opacity;
			cycle_flag = false;
			setOpacity(cur_opacity);
			//stop cycling
			interval = null;
			//on complete, run callback
			done_fading = true;
			callback();
			inner_working = false;
			return true;
		}
		else if (cur_opacity <= 0) {
			cur_opacity = 0;
			cycle_flag = false;
			setOpacity(cur_opacity);
			//stop cycling
			interval = null;
			//bring back all select boxes (if any)
			if (select_box != null) {
				for (var i=0; i<select_box.length; i++) {
					select_box[i].style.visibility = "visible";
				}
			}

			if (objects != null) {
				for (var i=0; i<objects.length; i++) {
					objects[i].style.visibility = "visible";
				}
			}

			if (embeds != null) {
				for (var i=0; i<embeds.length; i++) {
					embeds[i].style.visibility = "visible";
				}
			}

			removeObj();
			return true;
		}
		//cycling is needed...
		setOpacity(cur_opacity);
		interval = setTimeout(cycleOpacity, wait);

	}

	this.fadeIn = function()
	{
		if (done_fading) {
			callback();
			return;
		}
		//hide all select box (thank you internet explorer..)
		var selects = document.getElementsByTagName('select');

		for (var i=0, j=0; i<selects.length; i++) {

			if (selects[i].style.visibility != "hidden") {
				if (select_box == null) {
					select_box = new Array();
				}
				select_box[j++] = selects[i];
				selects[i].style.visibility = "hidden";
			}
		}

		var flashes = document.getElementsByTagName('object');

		for (var i=0, j=0; i<flashes.length; i++) {
			if (flashes[i].style.visibility != "hidden") {
				if (objects == null) {
					objects = new Array();
				}
				objects[j++] = flashes[i];
				objects[i].style.visibility = "hidden";
			}
		}

		var flashes = document.getElementsByTagName('embed');

		for (var i=0, j=0; i<flashes.length; i++) {
			if (flashes[i].style.visibility != "hidden") {
				if (embeds == null) {
					embeds = new Array();
				}
				embeds[j++] = flashes[i];
				embeds[i].style.visibility = "hidden";
			}
		}

		step = speed / tar_opacity;
		interval = setTimeout(cycleOpacity, wait);
		return true;
	}

	this.fadeOut = function() {
		if (mask_obj == null) {
			return false;
		}
		//have we finished fadeing in?
		if (interval != null) {
			clearTimeout(interval);
		}
		step = -(speed / tar_opacity);
		interval = setTimeout(cycleOpacity, wait);
	}
}

function showYouTube() {
	//should be null if opened from iframe
	if (fader == null) {
		fader = new pageMask(40, 200, fader_iframe, showRealYouTube);
	}
	fader.fadeIn();
}

function showRealYouTube() {
	var obj = document.getElementById(youtube_id);
	obj.style.display = "block";
}

//wrapper function for cruise select on search result
var cselectObj = null;
var order_img = 'images/order.gif';
var order_chk_img = 'images/order_checked.gif';

function selectCruise(id, obj) {
	ajaxSelectRedirect(id);
	//document.getElementById('continue_os').style.display='block'
	//mark current row
	obj.parentNode.parentNode.className = "bold";
	obj.style.backgroundImage = 'url('+order_chk_img+')';
	if (cselectObj != null && cselectObj != obj) {
		cselectObj.style.backgroundImage = 'url('+order_img+')';
		//is it still on page?
		if (cselectObj.parentNode && cselectObj.parentNode.parentNode)
			cselectObj.parentNode.parentNode.className = "";
	}
	cselectObj = obj;

}

/*----------------------------
Easy form validation
Liran Oz - 2008
makes it easier to handle possibilities of 100+ items in a single form
----------------------------*/
function formItem(_id, _type, _req, _eVar) {
	var id = _id;
	var type = _type;
	var req = _req;
	var eVar = _eVar;
	var val="";

	this.getId = function() {
		return id;
	}

	this.getType = function() {
		return type;
	}

	this.getValue = function() {
		obj = document.getElementById(id);
		switch(type) {
			case 'text':
			case 'int':
			case 'id_number':
			case 'email':
				val = obj.value;
				break;
			case 'select':
				if (obj.selectedIndex < 0)
					return false;
				val = obj.options[obj.selectedIndex].value;
				break;
		}

		return val;
	}

	this.setFocus = function() {
		obj = document.getElementById(id);
		if (obj && obj.focus)
			obj.focus();
	}

	this.isValid = function() {
		if (eVar != "") {
			eval("var needed = "+eVar+";");
			if (needed == false)
				return true;
		}
		if (!req) {
			return true;
		}
		obj = document.getElementById(id);
		switch(type) {
			case 'text':
				val = obj.value;
				if (val.length > 0) {
					return true;
				}
				return false;

			case 'select':
				if (obj.selectedIndex < 0)
					return false;
				val = obj.options[obj.selectedIndex].value;
				//what to do with that?
				return true;

			case 'id_number':
				val = obj.value;
				return checkidnum(val);

			case 'int':
				val = obj.value;

				if (val.match(/[^\d]+/g) ) {
					return false;
				}

				if (val.length > 0) {
					return true;
				}
				return false;

			case 'crd_num':
				val = obj.value;

				if (val.match(/[^\d]+/g) )
					return false;

				//use mod10 function
				var res = Mod10(val);

				if (res == false)
					return false;

				if (val.length == 8 || val.length == 16)
					return true;

				return false;

			case 'crd_dgt':
				val = obj.value;

				if (val.match(/[^\d]+/g) ) {
					return false;
				}

				if (val.length == 3) {
					return true;
				}
				return false;

			case 'email':
				val = obj.value;
				if (!val.match(/^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_]+((\.[a-zA-Z0-9_]+)*)$/)) {
					return false;
				}
				return true;

			case 'chkbox':
				return true;

			case 'none':
				return true;
		}
		return false;
	}
}

function checkidnum(idnum) {
 // FUNCTION FOR VALIDATING ID NUMBER
 //Addition - can only accept numbers! - Liran Oz
 	//trim - if exists
 	idnum = idnum.replace('-', '');

 	if (idnum.match(/[^0-9]/))
 		return false;

    while (idnum.length<9) {
        idnum="0"+idnum;
    }

    idnum1=idnum.substr(0,1)*1;
    idnum2=idnum.substr(1,1)*2;
    idnum3=idnum.substr(2,1)*1;
    idnum4=idnum.substr(3,1)*2;
    idnum5=idnum.substr(4,1)*1;
    idnum6=idnum.substr(5,1)*2;
    idnum7=idnum.substr(6,1)*1;
    idnum8=idnum.substr(7,1)*2;
    idnum9=idnum.substr(8,1)*1;

    if (idnum1>9) idnum1=(idnum1%10)+1
    if (idnum2>9) idnum2=(idnum2%10)+1
    if (idnum3>9) idnum3=(idnum3%10)+1
    if (idnum4>9) idnum4=(idnum4%10)+1
    if (idnum5>9) idnum5=(idnum5%10)+1
    if (idnum6>9) idnum6=(idnum6%10)+1
    if (idnum7>9) idnum7=(idnum7%10)+1
    if (idnum8>9) idnum8=(idnum8%10)+1
    if (idnum9>9) idnum9=(idnum9%10)+1

    var sumval=idnum1+idnum2+idnum3+idnum4+idnum5+idnum6+idnum7+idnum8+idnum9;
    if(sumval == 0)
     return false;
    sumval=sumval%10
    if (sumval>0) {
        return false;
    }
  return true;
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: David Leppek :: https://www.azcode.com/Mod10

Basically, the alorithum takes each digit, from right to left and muliplies each second
digit by two. If the multiple is two-digits long (i.e.: 6 * 2 = 12) the two digits of
the multiple are then added together for a new number (1 + 2 = 3). You then add up the
string of numbers, both unaltered and new values and get a total sum. This sum is then
divided by 10 and the remainder should be zero if it is a valid credit card. Hense the
name Mod 10 or Modulus 10. */

function Mod10(ccNumb) {  // v2.0
	var valid = "0123456789"  // Valid digits in a credit card number
	var len = ccNumb.length;  // The length of the submitted cc number
	var iCCN = parseInt(ccNumb, 10);  // integer of ccNumb
	var sCCN = ccNumb.toString();  // string of ccNumb
	sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
	var iTotal = 0;  // integer total set at zero
	var bNum = true;  // by default assume it is a number
	var bResult = false;  // by default assume it is NOT a valid cc
	var temp;  // temp variable for parsing string
	var calc;  // used for calculation of each digit

// Determine if the ccNumb is in fact all numbers
for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}

// if it is NOT a number, you can either alert to the fact, or just pass a failure
if(!bNum){
  /*alert("Not a Number");*/bResult = false;
}

// Determine if it is the proper length
if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
  bResult = false;
} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
  if(len >= 15){  // 15 or 16 for Amex or V/MC
    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
      calc = parseInt(iCCN, 10) % 10;  // right most digit
      calc = parseInt(calc, 10);  // assure it is an integer
      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
      i--;  // decrement the count - move to the next digit in the card
      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
      calc = parseInt(iCCN, 10) % 10 ;    // NEXT right most digit
      calc = calc *2;                                 // multiply the digit by two
      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
      switch(calc){
        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
      }
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
    bResult = true;  // This IS (or could be) a valid credit card number.
  } else {
    bResult = false;  // This could NOT be a valid credit card number
    }
  }
}
// change alert to on-page display or other indication as needed.
  return bResult; // Return the results
}

// ---------------------------------------------------------------------------------------------
// bubble-tooltip.js
// ---------------------------------------------------------------------------------------------
/************************************************************************************************************
Ajax dynamic list
Copyright (C) September 2005  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com
	
************************************************************************************************************/	

var select_box = null;

function showToolTip(e,text){
	if(document.all)e = event;
	if (/msie 6/i.test (navigator.userAgent)) //only override IE
	{
		hideselect();
	}
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}	

function hideToolTip() {
	document.getElementById('bubble_tooltip').style.display = 'none';
	if (/msie 6/i.test (navigator.userAgent)) //only override IE
	{
		dispselect();
	}
}

function hideselect() {
	//hide all select box (thank you internet explorer..)
	var selects = document.getElementsByTagName('select');
	for (var i=0, j=0; i<selects.length; i++) {
		if (selects[i].style.visibility != "hidden") {
			if (select_box == null) {
				select_box = new Array();
			}
			select_box[j++] = selects[i];
			selects[i].style.visibility = "hidden";
		}
	}
}

function dispselect() {
	//hide all select box (thank you internet explorer..)
	var selects = document.getElementsByTagName('select');
	for (var i=0;i<selects.length; i++) {
		if (selects[i].style.visibility == "hidden") {
			selects[i].style.visibility = "visible";
		}
	}
}

// ---------------------------------------------------------------------------------------------
// Easing.v1.3.js
// ---------------------------------------------------------------------------------------------

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright ֲ© 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright ֲ© 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
