/* to show customer feed backs as slide show in application n uses page*/
showFeedBacks = function(feedBack,cust,country){


	if(typeof(fb_counter) == 'undefined'){
		fb_counter = 0;
	}
	f = feedBack[fb_counter];
	n = cust[fb_counter];
	c = country[fb_counter];



	document.getElementById('customerfeedBack_1').innerHTML = f;
	if(c != ''){
		document.getElementById('customerfeedBack_2').innerHTML = n +', '+ c;
	}else{
		document.getElementById('customerfeedBack_2').innerHTML = n;
	}

	if(fb_counter ==  feedBack.length-1){
		fb_counter = 0;
	}else{
		fb_counter++;
	}
	setTimeout("showFeedBacks(feedBack,cust,country)",5000);
}

var DDSPEED = 10;
var DDTIMER = 15;

function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');

  // to remove the color change whn we move mouse to tip 
  document.getElementById(id + '-ddcontent').style.opacity='1';

  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
   //document.getElementById(id + '-ddheader').className="";
}

function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }

 //document.getElementById(id + '-ddheader').className="dropdownSelect";
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
	
  }
  if(dist <= 1 && d == 1){
    dist = 1;	
  }
  if(d==1)//added by roshin
   c.style.height = currh + (dist * d) + 'px';
  else {//added by roshin

   var browser=navigator.appName;

  
    if ((browser=="Microsoft Internet Explorer"))
    {
        c.style.height = parseInt(currh + (dist * d))-  parseInt('0') + 'px';//added by roshin
    }
	  
	 else{
		  
		 c.style.height = parseInt(currh + (dist * d))-  parseInt('4') + 'px';//added by roshin
	// c.style.height = currh + (dist * d);
	  //c.style.height = '0px';
	  
	 }

	  
  }
  c.style.opacity = currh / c.maxh;
  
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
	// to solve the issue , when there is only one <li> in orange menu
	/*if($.browser.mozilla && document.getElementById('orange-ddcontent').childNodes[0].childNodes.length==1 && c.id=='orange-ddcontent') {
		c.style.opacity = 1;
	 }*/
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
		
	  // to solve the issue , when there is only one <li> in orange menu
	  /*if($.browser.mozilla && document.getElementById('orange-ddcontent').childNodes[0].childNodes.length==1 && c.id=='orange-ddcontent') {
			c.style.height = '0px';
	  }*/
  
}


getContactMapDirection = function(to_location){
	from_location = document.getElementById("contactDirLocation").value
	document.getElementById("route").style.visibility = 'visible';
	document.getElementById("route").innerHTML = '';
	if(typeof(directions)!="undefined"){
		directions.clear();
	}
	directionsPanel = document.getElementById("route");
	directions = new GDirections(contactmap, directionsPanel);
	directions.load("from: "+from_location+" to: "+to_location+"");
	//directions.load("from: "+to_location+" to: "+from_location+"");
}

function getMapDirection(e,from_location){
    var key;
    if (window.event){
        e = window.event;
		key = e.keyCode;
    }else if(e.which){
		key = e.which; 
	}
	if ( key == '13' ){
		getContactMapDirection(from_location);
	}
}

function googleMapLayer()
{
	mapWindow = dhtmlmodal.open('googleMapBox', 'div', 'googleMap', 'Reseller Locations', 'width=600px,height=300px,center=1,resize=0,scrolling=0');
	initialize(arguments);
}
function initialize(address) {
	var map = new GMap2(document.getElementById("googleMapDiv"));
	new GKeyboardHandler(map);
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	var geocoder = new GClientGeocoder();
	for(var i=0;i<address.length-1;i++){
		setCityMarker(address[i],address,map,geocoder,i);
	}
}

function setCityMarker(name,address,map,geocoder,counter){
	geocoder.getLatLng(name,function(point) {
		if(point){
			map.setCenter(point,2);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			marker.bindInfoWindowHtml(address[counter]);
		}else{
			geocoder.getLatLng(name,function(point) {
				if(point){
					map.setCenter(point,2);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					marker.bindInfoWindowHtml(address[counter]);
				}else{
				}
			});
		}
	});
}



$(document).ready(function() {

	//$.noConflict();
	$('#spectrum_1').mouseover(function() {
		var offset = $('#spectrum_1').offset();
		var leftPos = (offset.left) - 110+"px"
		$('#ord_pic').css("display","block");
		$('#ord_pic').css("position","absolute");
		$('#ord_pic').css("left",leftPos);
		$('#ord_pic').css("top",offset.top);
	});
	
	$('#spectrum_1').mouseout(function() {
		$('#ord_pic').css("display","none");
	});
	$('#spectrum_2').mouseover(function() {
		var offset = $('#spectrum_2').offset();
		var leftPos = (offset.left) - 110+"px"
		$('#day_pic').css("display","block");
		$('#day_pic').css("position","absolute");
		$('#day_pic').css("left",leftPos);
		$('#day_pic').css("top",offset.top);
	});
	$('#spectrum_2').mouseout(function() {
		$('#day_pic').css("display","none");
	});
	
	$('#spectrum_3').mouseover(function() {
		var offset = $('#spectrum_3').offset();
		var leftPos = (offset.left) - 110+"px"
		$('#viva_pic').css("display","block");
		$('#viva_pic').css("position","absolute");
		$('#viva_pic').css("left",leftPos);
		$('#viva_pic').css("top",offset.top);
	});
	$('#spectrum_3').mouseout(function() {
		$('#viva_pic').css("display","none");
	});

// to show all layers
	$('#showallspectlayers').click(function() {

		var offset1 = $('#spectrum_1').offset();
		var leftPos1 = (offset1.left) - 110+"px"
		var top1     = (offset1.top) -50+"px"
		$('#ord_pic').css("display","block");
		$('#ord_pic').css("position","absolute");
		$('#ord_pic').css("left",leftPos1);
		$('#ord_pic').css("top",top1);

		var offset2 = $('#spectrum_2').offset();
		var leftPos2 = (offset2.left) - 110+"px"
		var top2 = (offset2.left) -10+"px"
		$('#day_pic').css("display","block");
		$('#day_pic').css("position","absolute");
		$('#day_pic').css("left",leftPos2);
		$('#day_pic').css("top",top2);
		
		var offset3 = $('#spectrum_3').offset();
		var leftPos3 = (offset3.left) - 110+"px"
		var top3 = (offset3.top);

		$('#viva_pic').css("display","block");
		$('#viva_pic').css("position","absolute");
		$('#viva_pic').css("left",leftPos3);
		$('#viva_pic').css("top",top3);





	});

	$('#showallspectlayers').mouseout(function() {
		$('#ord_pic').css("display","none");
		$('#day_pic').css("display","none");
		$('#viva_pic').css("display","none");
	}); 




 
  
});


var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
dropdownindicator: '', //specify full HTML to add to end of each menu item with a drop down menu
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" in IE5.5/IE6? (1=yes, 0=no)

//No need to edit beyond here////////////////////////

dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
},

swipeeffect:function(){
	if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
		this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
		this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
	}
	else
		return
	this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 25)
},

css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add" && !needle.test(el.className))
		el.className+=" "+targetclass
},

showhide:function(obj, e){
	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
	if (this.enableswipe==1){
		if (typeof this.swipetimer!="undefined")
			clearTimeout(this.swipetimer)
		obj.clip="rect(0 auto 0 0)" //hide menu via clipping
		this.bottomclip=0
		this.swipeeffect()
	}
	obj.visibility="visible"
	this.css(this.asscmenuitem, "selected", "add")
},

clearbrowseredge:function(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
		this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
			edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
		var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
		this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
		if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
			edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
			if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
},

dropit:function(obj, e, dropmenuID){
	if (this.dropmenuobj!=null) //hide previous menu
		this.hidemenu() //hide menu
	this.clearhidemenu()
	this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu

	this.asscmenuitem=obj //reference associated menu item
	this.showhide(this.dropmenuobj.style, e)
	this.dropmenuobj.x=this.getposOffset(obj, "left")
	this.dropmenuobj.y=this.getposOffset(obj, "top")
	/*var align = document.getElementById(dropmenuID).getAttribute('menualign');
	if(align=='right'){
		this.dropmenuobj.style.left=null;
		this.dropmenuobj.style.right = obj.offsetLeft - 7*obj.offsetWidth+"px";
		}else{
			this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"	
	}*/	
		//jijo top and left altered by  6 and 15
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px";
	this.dropmenuobj.style.top=6+this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px";
	this.positionshim() //call iframe shim function
},

positionshim:function(){ //display iframe shim function
	if (this.enableiframeshim && typeof this.shimobject!="undefined"){
		if (this.dropmenuobj.style.visibility=="visible"){
			this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
			this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
			this.shimobject.style.left=this.dropmenuobj.style.left
			this.shimobject.style.top=this.dropmenuobj.style.top
		}
	this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
	}
},

hideshim:function(){
	if (this.enableiframeshim && typeof this.shimobject!="undefined")
		this.shimobject.style.display='none'
},

isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},

dynamichide:function(m, e){
	if (!this.isContained(m, e)){
		this.delayhidemenu()
	}
},

delayhidemenu:function(){
	this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
},

hidemenu:function(){
	this.css(this.asscmenuitem, "selected", "remove")
	this.dropmenuobj.style.visibility='hidden'
	this.dropmenuobj.style.left=this.dropmenuobj.style.top=0
	this.hideshim()
},

clearhidemenu:function(){
	if (this.delayhide!="undefined")
		clearTimeout(this.delayhide)
},

addEvent:function(target, functionref, tasktype){
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},
	 startchrome:function(){
		if (!this.domsupport)
			return
		this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		for (var ids=0; ids<arguments.length; ids++){
			var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
			for (var i=0; i<menuitems.length; i++){
				if (menuitems[i].getAttribute("rel")){
					var relvalue=menuitems[i].getAttribute("rel")
					var asscdropdownmenu=document.getElementById(relvalue)
					this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
					this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
					this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
					try{
						menuitems[i].innerHTML=menuitems[i].innerHTML+" "+this.dropdownindicator
					}catch(e){}
					this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
						if (!cssdropdown.isContained(this, e)){
							var evtobj=window.event || e
							cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
						}
					}, "mouseover")
					this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
					this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
				}
			} //end inner for
		} //end outer for
		if (window.createPopup && !window.XmlHttpRequest &&!this.iframeshimadded){ //if IE5.5 to IE6, create iframe for iframe shim technique
			document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
			this.shimobject=document.getElementById("iframeshim") //reference iframe object
			this.iframeshimadded=true
		}
	} //end startchrome


}


function ChangeLanguage(lang)
{	
	/*if ( "undefined" != typeof(blogtop )) {
		blogtop.document.getElementById("frmVivalite").action = blogtop.location.href+"?url="+window.location.href;
		blogtop.document.getElementById("hidLangIndex").value = lang;
		blogtop.document.getElementById("frmVivalite").submit();
	}else{*/
		document.getElementById("hidLangIndex").value=lang;
		document.getElementById("frmVivalite").submit();
	//}
}


ChangeCurrency = function(currencyId){
	/*if("undefined" != typeof(blogtop)){
		blogtop.document.getElementById("frmVivalite").action = blogtop.location.href+"?url="+window.location.href;
		blogtop.document.getElementById("hidCurrencyIndex").value = currencyId;
		blogtop.document.getElementById("frmVivalite").submit();
	}else{*/
		document.getElementById("hidCurrencyIndex").value=currencyId;
		document.getElementById("frmVivalite").submit();

//	}
}



function getCookie(name)
{
	var c = document.cookie;
	//var matches = c.match(new RegExp("(?:^|; )" + escapeString(name,'') + "=([^;]*)"));
	var matches = c.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
	return matches ? decodeURIComponent(matches[1]) : undefined; // String or undefined

}
escapeString = function(str, except){
	//	summary:
	//		Adds escape sequences for special characters in regular expressions
	// except:
	//		a String with special characters to be left unescaped

//	return str.replace(/([\f\b\n\t\r[\^$|?*+(){}])/gm, "\\$1"); // string
	return str.replace(/([\.$?*!=:|{}\(\)\[\]\\\/^])/g, function(ch){
		if(except && except.indexOf(ch) != -1){
			return ch;
		}
		return "\\" + ch;
	}); // String
}

function setCountry(cntyid){
	document.getElementById("hidValCountryAction").value='changecountry';
	document.getElementById("hidValCountryId").value=cntyid;
	document.getElementById("frmVivalite").submit();
}



/********************FAQ PAGE*********************/
toggleFAQ = function(ansid, qnid){
	if(document.getElementById(ansid).style.display == 'none'){
		document.getElementById(ansid).style.display = 'block'
		document.getElementById(qnid).className='minus'
	}else{
		document.getElementById(ansid).style.display = 'none'
		document.getElementById(qnid).className='plus'
	}
}
toggleAll = function(count,display){
	for(var i=0; i<count; i++){
		document.getElementById('ans_'+i).style.display = display;
		document.getElementById('qn_'+i).className = (display == 'none') ? 'plus' : 'minus';
	}
}



function showShippingAddress(shippingAddr,shippingMsg)
{
	document.getElementById(shippingAddr).style.display = '';
	document.getElementById(shippingMsg).style.display = 'none';
}

function hideShippingAddress(shippingAddr,shippingMsg)
{
	document.getElementById(shippingAddr).style.display = 'none';
	document.getElementById(shippingMsg).style.display = '';
}








    createAccount   = function() {
	var gender		   = $('[name=gender]').val();
	var fname		   = $('[name=fname]').val();
	var lname		   = $('[name=lname]').val();
	var phoneCntry     = $('[name=phoneCntry]').val();
	var phoneArea      = $('[name=phoneArea]').val();
	var phoneNo        = $('[name=phoneNo]').val();
	var mobCntry       = $('[name=mobCntry]').val();
	var mobNo		   = $('[name=mobNo]').val();
	var email		   = $('[name=email]').val();
	var invStreet	   = $('[name=invStreet]').val();
	var invAdditional  = $('[name=invAdditional]').val();
	var invZip		   = $('[name=invZip]').val();
	var invCity		   = $('[name=invCity]').val();
	var invRegion	   = $('[name=invRegion]').val();
	var shipStreet	   = $('[name=shipStreet]').val();
	var shipAdditional = $('[name=shipAdditional]').val();
	var shipZip		   = $('[name=shipZip]').val();
	var shipCity	   = $('[name=shipCity]').val();
	var shipRegion     = $('[name=shipRegion]').val();
	var oldPasswd      = $('[name=oldPasswd]').val();
	var newPasswd      = $('[name=newPasswdCnfd]').val();
	var invCntry     = $('[name=l_invoice_country]').val();;
	var shipCountry    = $('[name=l_shipment_country]').val();;
	
	var sameDelAdd = 'y';
	if(document.getElementById('shippingAddr').style.display == ''){
		sameDelAdd = 'n';//invoice and delivery address same
	}
	if(!validateContactDetails(sameDelAdd)) {
		return false;
	} 


	 if(document.getElementById('loginExistMsg').style.display == 'block'){
		//no passwd match
			alert(alerts['1038']);
		document.forms[0].email.focus();
		return false;
	}

	$.getJSON(
		'ajax.php?action=fmd&id=42',
			{
				gender		   : gender,
				fname		   : fname,
				lname		   : lname,
				phoneCntry	   : phoneCntry,
				phoneArea	   : phoneArea,
				phoneNo		   : phoneNo,
				mobCntry	   : mobCntry,
				mobNo		   : mobNo,
				email		   : email,
				invStreet	   : invStreet,
				invAdditional  : invAdditional,
				invZip		   : invZip,
				invCity		   : invCity,
				invCntry	   : invCntry,
				invRegion	   : invRegion,
				shipStreet	   : shipStreet,
				shipAdditional : shipAdditional,
				shipZip		   : shipZip,
				shipCity	   : shipCity,
				shipRegion	   : shipRegion,
				oldPasswd	   : oldPasswd,
				newPasswd	   : newPasswd,
				sameAdd		   : sameDelAdd,
				shipCountry	   : shipCountry,
				hidAction		   : 'CreateAccount'
			},
			function (response,responsetext) {
				window.location="my_account.html";
			}
	);
  };


// to make the prod scrool and event scroll number text decoration none
function 	makeTextDecNone(elmtid,count){
	for (i=1; i<=count; i++){
		id= elmtid+i ;
		document.getElementById(id).style.textDecoration  = 'none';
	}
}





 






beforeAfterExample = function(imageNames){//for applicationUses.tpl
	if(typeof(imageIndx)=='undefined'){
		imageIndx=2;
	}if(imageIndx==imageNames.length){
		imageIndx=0;
	}
	document.getElementById('afterEgImg').src = 'tl_files/img/' + imageNames[imageIndx++];
	document.getElementById('beforeEgImg').src = 'tl_files/img/' + imageNames[imageIndx++];
}



//logo fading in product range
function so_init()
{
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);

	imgs = d.getElementById('rotator').getElementsByTagName('div');
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;

	setTimeout(so_xfade,3000);
}

function so_xfade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}



// spectrum switch in what is full spectrum page

function clickSwitch(node){
	switch(node.id) {
		case "switch-vivalite"  :
			var status = document.getElementById("vivalite_img").className;
			if(status == 'vivalite_on'){
				node.className = "deact";
				document.getElementById("vivalite_img").className="vivalite_off";				
			}else {
				node.className = "act";
				document.getElementById("vivalite_img").className="vivalite_on";
			}
		break;
		case "switch-standard":
			var status = document.getElementById("std_img").className;
			if(status == 'std_on'){
				document.getElementById("std_img").className="std_off";
				node.className = "deact";
			}else{ 
				document.getElementById("std_img").className="std_on";
				node.className = "act";
			}
		break;
	}
}




function openBeforeImageLayer(){
//Open a modal window populated with the contents of a hidden DIV, and assign the result to a global variable called "emailwindow"
	dhtmlmodal.open('layername', 'div', 'beforeImageDiv', 'With Normal Halogen', 'width=350px,height=340px,center=1,resize=0,scrolling=0');
}

function openAfterImageLayer(){
//Open a modal window populated with the contents of a hidden DIV, and assign the result to a global variable called "emailwindow"
	dhtmlmodal.open('layername', 'div', 'afterImageDiv', 'With Viva-Lite® Halogen', 'width=350px,height=340px,center=1,resize=0,scrolling=0');
}


showQuotes = function(quotes,names){//for applicationUses.tpl
	if(typeof(quoteIndx)=='undefined' && typeof(namesIndx)=='undefined'){
		quoteIndx=1;namesIndx=1;
	}if(quoteIndx==quotes.length && quoteIndx==names.length ){
		quoteIndx=0;namesIndx=0;
	}
	document.getElementById('quoteText').innerHTML = quotes[quoteIndx++];
	document.getElementById('quoteName').innerHTML = names[namesIndx++];
}

/**********************************events page driving direction******************************/
googleDirectionLayer = function(fromLocation){
	document.getElementById('dirFrom').value = fromLocation;
	dirWindow = dhtmlmodal.open('googleDirBox', 'div', 'googleDirectionMap',alerts['1000'], 'width=600px,height=300px,center=1,resize=0,scrolling=0');
	resellerMap(fromLocation,13/*zoom level*/);
}

function geteventDirection(e){
    var key;
    if (window.event){
        e = window.event;
		key = e.keyCode;
    }else if(e.which){
		key = e.which; 
	}
	if ( key == '13' ){
		getEventDirectionMap();
	}
}
getEventDirectionMap = function(){
	fromLocation = document.getElementById('dirFrom').value;
	toLocation = document.getElementById("eventDirLocation").value
	document.getElementById("route").style.visibility = 'visible';
	document.getElementById("route").innerHTML = '';
	if(typeof(directions)!="undefined"){
		directions.clear();
	}
	directionsPanel = document.getElementById("route");
	directions = new GDirections(map, directionsPanel);
	//directions.load("from: "+fromLocation+" to: "+toLocation+"");
	directions.load("from: "+toLocation+" to: "+fromLocation+"");
}

/*about us page reseller map*/
function resellerMap(place,zoom) {
	var zoom = (arguments[1]) ? arguments[1] : 5;
	map = new google.maps.Map2(document.getElementById("resellerLocation"));
	new GKeyboardHandler(map);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMenuMapTypeControl());
	var geocoder = new GClientGeocoder();
	geocoder.getLatLng(place,function(point){
		/*if(point=="" || point==null){
			document.getElementById("resellerLocation").style.display = 'none';
		return;
		}*/
		map.setCenter(point,zoom);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.bindInfoWindowHtml(place);
	});
}






sendNewsletterSubscription = function (){
	var email     =  document.getElementById('mce-EMAIL').value;
	var interests =  $('#mce-group-2-0').val()+','+$('#mce-group-2-1').val()+','+$('#mce-group-2-2').val();
	 if( email.match(/^ *$/)){
		//no email
		alert(alerts['1001']);
		document.getElementById('mce-EMAIL').focus();
		return false;
	}else if(!(validateEmail(email))){
		//invalid email
		alert(alerts['1002']);
		document.getElementById('mce-EMAIL').focus();
		return false;
	}


			$("#newsletterHP").fadeOut("slow",function(){
					 $("#newsletterHP").css('display','none');
					 $("#newsletterHP1").css('display','none');
					 $("#newsletterHPMessage").fadeIn("slow");
			});

		 $.getJSON(
		'ajax.php?action=fmd&id=54',
			{
				newsemail       : email,
				newsInterests   : interests,
				newsLetterFname   : '',
				newsLetterLname   : '',
				newsletterGender   : '',
				newsGender        : '',
				newsCountry     : $('#mce-CNTY').val(),
				newsLanguage    : $('#mce-LANG').val(),
				newsZip   : '',
				newsCity  :  '',
				newsletterVal : $('#mce-NEWSLETTER').val(),
				newsCustVal :  '',
				newsCompany :  '',
				hidAction       : 'homeNewsLetter'
			},
			function (response,responsetext) {
				
			}
		);

}



hideInput = function (id,fieldval){

		if(document.getElementById(id).value==fieldval){

			document.getElementById(id).value= '';

		}


}
showInput = function (id,fieldval){

		if(document.getElementById(id).value==''){

			document.getElementById(id).value= fieldval;

		}


}





chkEnter = function(e){
	var key;
    if (window.event){
		e = window.event;
		key = e.keyCode;
    }else if(e.which){
        key = e.which;
    }
    if ( key == '13' ){
        sendNewsletterSubscription();
        return false;
    }else{
        return true;
    }
}




submitNewsLetter = function (){
	if(!validateNewsLetter()) {
		return false;
	} 






		genid = $('#mce-TITLE :selected').attr('indx');


		interests ='';
		if($('#mce-group-2-0').is(':checked')){
			interests +=$('#mce-group-2-0').val();
		}
		if($('#mce-group-2-1').is(':checked')){
			interests += ','+$('#mce-group-2-1').val();
		}
		if($('#mce-group-2-2').is(':checked')){
			interests +=','+$('#mce-group-2-2').val();
		}


		if(!interests){
			interests =$('#mce-group-2-0').val()+','+$('#mce-group-2-1').val()+','+$('#mce-group-2-2').val();
		}

		$("#newsletterwait").css('display','block');
		$("#newslettersend").css('display','none');


		 $.getJSON(
		'ajax.php?action=fmd&id=54',
			{
				newsemail       : $('#mce-EMAIL').val(),
				newsInterests   : interests,
				newsCountry     : $('#mce-CNTY').val(),
				newsLanguage    : $('#mce-LANG').val(),
				newsLetterFname : $('#mce-FNAME').val(),
				newsLetterLname : $('#mce-LNAME').val(),
				newsGender       : $('#mce-TITLE').val(),
				newsletterGender : genid,
				newsZip   : '',
				newsCity  :  '',
				newsletterVal : $('#mce-NEWSLETTER').val(),
				newsCustVal :  '',
				newsCompany :  '',
				hidAction        : 'subscribeNews'
			},
			function (response,responsetext) {

				$("#newsletterwait").css('display','none');
				$("#newslettersend").css('display','block');


				$('#newsletterHPMessage').css("display","block");
				$('#mce-EMAIL').val('');
				$('#mce-FNAME').val('');
				$('#mce-LNAME').val('');
				$('#mce-group-2-0').attr('checked',false);
				$('#mce-group-2-1').attr('checked',false);
				$('#mce-group-2-2').attr('checked',false);

				 
			}
		);

}




validateNewsLetter = function(){
	if( document.getElementById('mce-FNAME').value.match(/^ *$/)){
		//no first name
		alert(alerts['1003']);
		document.getElementById('mce-FNAME').focus();
		return false;
	}else if( document.getElementById('mce-LNAME').value.match(/^ *$/)){
		//no last name
		alert(alerts['1004']);
		document.getElementById('mce-LNAME').focus();
		return false;
	}else if( document.getElementById('mce-LNAME').value.match(/^ *$/)){
		//no email
		alert(alerts['1001']);
		document.getElementById('mce-EMAIL').focus();
		return false;
	}else if(!(validateEmail(document.getElementById('mce-EMAIL').value))){
		//invalid email
		alert(alerts['1002']);
		document.getElementById('mce-EMAIL').focus();
		return false;
	}else
		return true;
}



/* contact us */


showCheckOther = function(value){
	if(value=='other'){
		document.getElementById("otherSubjectDiv").style.display = 'inline';
	}else{
		document.getElementById("otherSubjectDiv").style.display = 'none';
	}
	if(value=='12'){
		document.getElementById("trialinstall").style.display = 'inline';
		document.getElementById("trialinstallation").value = 'y';
	}else{
		document.getElementById("trialinstall").style.display = 'none';
		document.getElementById("trialinstallation").value = 'n';
	}


	return;
}

sendContactUs = function(){
	if(validateContactUs()){

		var cntyname = document.forms[0].country.options[document.forms[0].country.options.selectedIndex].text;
		var gender = document.forms[0].contactUsGender.options[document.forms[0].contactUsGender.options.selectedIndex].text;
		if(document.forms[0].subject.value == 'other'){
			var subject =  document.forms[0].otherSubject.value;
		}else{
			var subject =  document.forms[0].subject.options[document.forms[0].subject.options.selectedIndex].text;
		}


		if(document.forms[0].chkCallBack.checked){
			var chkCallBack = 'y';
		}else{
			var chkCallBack = 'n';
		}
		if(document.forms[0].chkDelRecpt.checked){
			var chkDelRecpt = 'y';
		}else{
			var chkDelRecpt = 'n';
		}
		if(document.forms[0].chkSendCopy.checked){
			var chkSendCopy = 'y';
		}else{
			var chkSendCopy = 'n';
		}

		if(document.forms[0].chkNewsletter.checked){
			var chkNewsletter = 'y';
		}else{
			var chkNewsletter = 'n';
		}
		document.getElementById('contactusmailperson').innerHTML = gender+' '+$('#lastName').val();


		$("#contactusdiv").fadeOut("slow",function(){
					 $("#contactusdiv").css('display','none');
					 $("#contactusfindus").css('display','none');
					 $("#contactusdottedline").css('display','none');
					 $("#contactusrhs").css('display','none');
					 $("#contactusthanksmsg").fadeIn("slow");
	   });

		genid = $('#contactUsGender :selected').attr('indx');
		var interests =  $('#mce-group-2-0').val()+','+$('#mce-group-2-1').val()+','+$('#mce-group-2-2').val();




		// $.getJSON(
		 $.post(
		'ajax.php?action=fmd&id=55',
			{
				mailid : $('#emailId').val(),
				genderindx : genid,
				firstName : $('#firstName').val(),
				lastName : $('#lastName').val(),
				companyName : $('#companyName').val(),
				phoneNumber : $('#phoneNumber').val(),
				countryIndx : document.forms[0].country.value,
				zip : $('#addresszip').val(),
				city : $('#addresscity').val(),
				subject : subject,
				detailDesc : $('#detailDesc').val(),
				chkCallBack : chkCallBack,
				chkDelRecpt : chkDelRecpt,
				chkSendCopy : chkSendCopy,
				chkNewsletter : chkNewsletter,
				heardAbt : $('#heardAbt').val(),
				noOfLamps : $('#noOfLamps').val(),
				countryName : cntyname,
				genderName : gender,

				newsInterests   : interests,
				newsCountry     : $('#mce-CNTY').val(),
				newsLanguage    : $('#mce-LANG').val(),
				newsZip   : $('#addresszip').val(),
				newsCity  :  $('#addresscity').val(),
				newsletterVal : $('#mce-NEWSLETTER').val(),
				newsCustVal :  '',
				newsCompany :  $('#companyName').val(),
				hidAction     : 'sendFeedback'
			},
			function (response,responsetext) {
				 
			}
		);


	}else{
		return false;
	}
}

validateContactUs = function(){
	var a = parseInt(document.forms[0].contactrandom1.value);
	var b = parseInt(document.forms[0].contactrandom2.value);


	var sum = a + b;
	var trialinstallation = document.forms[0].trialinstallation.value;
	if(document.forms[0].emailId.value.match(/^ *$/)){
		alert(alerts['1001']);
		document.forms[0].emailId.focus();
		return false;
	}else if(!(validateEmail(document.forms[0].emailId.value))){
		alert(alerts['1002']);
		document.forms[0].emailId.focus();
		return false;
	}else if(document.forms[0].firstName.value.match(/^ *$/)){
		alert(alerts['1003']);
		document.forms[0].firstName.focus();
		return false;
	}else if(document.forms[0].lastName.value.match(/^ *$/)){
		alert(alerts['1004']);
		document.forms[0].lastName.focus();
		return false;
	}else if(document.forms[0].country.value == 'new'){
		alert(alerts['1009']);
		document.forms[0].country.focus();
		return false;
	}else if((trialinstallation=='y') && (document.forms[0].noOfLamps.value.match(/^ *$/))){
		alert(alerts['1010']);
		document.forms[0].noOfLamps.focus();
		return false;
	}else if((trialinstallation=='y') &&  (! document.forms[0].noOfLamps.value.match(/^\s*\d+\s*$/))){
		alert(alerts['1011']);
		document.forms[0].noOfLamps.focus();
		return false;
	}else if((trialinstallation=='y') && (document.forms[0].noOfLamps.value < 1)){
		alert(alerts['1012']);
		document.forms[0].noOfLamps.focus();
		return false;
	}else if(document.forms[0].subject.value == 'new'){
		alert(alerts['1006']);
		document.forms[0].subject.focus();
		return false;
	}else if((document.forms[0].subject.value == 'other') && document.forms[0].otherSubject.value.match(/^ *$/)){
		alert(alerts['1007']);
		document.forms[0].otherSubject.focus();
		return false;
	}else if(document.forms[0].detailDesc.value.match(/^ *$/)){
		alert(alerts['1008']);
		document.forms[0].detailDesc.focus();
		return false;
	}else if(sum != document.forms[0].contactsum.value){
		alert(alerts['1005']);
		document.forms[0].contactsum.focus();
		return;
	}else{
		return true;
	}
}



/* prod detail page  */



function saveCustomerReview(productId){
	if($("#cust_name").val().match(/^ *$/)){
		alert(alerts['1014']);
		$('#cust_name').focus();
		return;
	}
	if($("#cust_email").val().match(/^ *$/)){
		alert(alerts['1001']);
		$("#cust_email").focus();
		return;
	}
	if(!(validateEmail($("#cust_email").val())))
		{
		alert(alerts['1002']);
		$("#cust_email").focus();
		return;
	}
	if($("#cust_loc").val().match(/^ *$/)){
		alert(alerts['1084']);
		$("#cust_loc").focus();
		return;
	}
	if($("#review_sub").val().match(/^ *$/)){
		alert(alerts['1007']);
		$("#review_sub").focus();
		return;
	}
	if($("#cust_review").val().match(/^ *$/)){
		alert(alerts['1015']);
		$("#cust_review").focus();
		return;
	}
	$.getJSON(window.location.pathname,{hidAction: "saveCustomerReview",
		productId:productId,
		customerName:$("#cust_name").val(),
		customerEmail:$("#cust_email").val(),
		customerReview:$("#cust_review").val(),
		cust_loc:$("#cust_loc").val(),
		review_sub:$("#review_sub").val(),
		customerRating:$('#hidCustomerRating').val(),
		publishReview:$('#publish_review').is(':checked')}, 
		function(data) {
		dhtmlmodal.close(emailwindow);
		openReviewConfirmationLayer();
	});
}







function openReviewConfirmationLayer(){
//Open a modal window populated with the contents of a hidden DIV, and assign the result to a global variable called "emailwindow"
	emailwindow = dhtmlmodal.open('EmailBox', 'div', 'productreviewMsg', document.getElementById("hidProductName").value, 'width=400px,height=100px,center=1,resize=0,scrolling=0');
}








function changeOptions(prodImgPath,optionId,prodId)
{



	if(optionId != "0" ){
		$('#addToCartBtn').css("display","none");
		$('#addToCartwait').css("display","block");
		
		$.getJSON(window.location.pathname,{hidAction: "loadProductOption",productId:prodId,optionId:optionId}, function(data) {
			HttpProductOptionResponse(prodImgPath,data)
			HttpProductImagesResponse(prodImgPath,data)
		});
	}
}





function HttpProductOptionResponse(prodImgPath,data)
{   //alert(data[0].prodPriceSymbolDelim);
	if(data[0]){

		
		prodPrice     = data[0].prodPriceSymbolDelim;
		prodrrPrice   = data[0].prodRrPriceSymbolDelim;
		prodsavePrice = data[0].savePrice;

		prodImage     = data[0].imgName;
		prod_pricewithoutcurrsymbol = data[3].prodPriceNoSymbol;
		rr_pricewithoutcurrsymbol   = data[3].prodRrPriceNoSymbol;
		special                     = data[3].specialexists;
		stockhandling               = data[0].stock_handling;
		stockstatus                 = data[0].stock_status;
		show_rrp                    = data[0].show_rrp;
		
		greenmsg  = document.getElementById("hidStockGreenMsg").value;
		yellowmsg = document.getElementById("hidStockYellowMsg").value;
		redmsg    = document.getElementById("hidStockRedMsg").value;

		if(stockhandling == 'm' && stockstatus =='y' ){
			$("#stockstatusimage").css('color','orange');
			stockmsg= yellowmsg;
		}else if(stockhandling == 'm' && stockstatus =='r'){
			$("#stockstatusimage").css('color','red');
			stockmsg= redmsg;
		}else{
			$("#stockstatusimage").css('color','green');
			stockmsg= greenmsg;
		}


		if(special=='y'){
			document.getElementById("specialimg").style.display='';
			document.getElementById("prodOurPrice").innerHTML=document.getElementById("hidSplPrice").value;
		}else{
			document.getElementById("specialimg").style.display='none';
			document.getElementById("prodOurPrice").innerHTML=document.getElementById("hidOurPrice").value;
		}

		$("#stockstatusimage").html('<b>&nbsp;&nbsp;'+stockmsg+'</b>');

		if((rr_pricewithoutcurrsymbol*1.0 < prod_pricewithoutcurrsymbol*1.0)|| show_rrp=='n'){
			$("#productPrice").html(prodPrice);
			$("#productrrPrice").html('');
			$("#productsavePrice").html('');
			$("#prodListPrice").css('display','none');
			$("#prodSavePrice").css('display','none');
		}else {
			$("#productPrice").html(prodPrice);
			$("#productrrPrice").css('display','block');
			$("#productrrPrice").html(prodrrPrice);
			$("#productsavePrice").css('display','block');
			$("#productsavePrice").html(prodsavePrice);
			$("#prodListPrice").css('display','block');
			$("#prodSavePrice").css('display','block');
		}
		fileId = data[0].fileId;

		if(fileId && typeof(data[2][fileId])!='undefined'){
			largeImgName = data[2][fileId].bigImgName;
			if(largeImgName != ''){

				result = "<a id='Zoomer' class='MagicZoom' rel='zoom-position:inner;zoom-fade: true;thumb-change: mouseover' title='"+$('#hidProductName').val()+"' style='cursor:pointer;'  href="+prodImgPath+"/large/"+largeImgName+"><img src="+prodImgPath+"/small/"+prodImage+" height='300' width='300' align='middle' style='cursor:pointer;' border='0'/></a>";

			}
		}else{
			result = "<img src="+prodImgPath+"/small/"+prodImage+" height='300' width='300' align='middle' />";
		}
		$('#productimagebig').html(result);
		MagicZoom.refresh();

		//$(function(){$('.productimagebig a').lightBox();});


	}
}




function HttpProductImagesResponse(prodImgPath,data)
{
	var result1 ='';
	var imgNames = '';
	var fileIds  = '';

	for(var i in data[2]){
		imgNames += data[2][i].bigImgName + ";"
		fileIds  += i + ";"
	}
	var pFileId = data[0].fileId;
	for(var i = 0; i < data[1].length; i++){
		prodImage	    = data[1][i].imgName;
		fileId          = data[1][i].fileId;
		if(fileId && typeof(data[2][fileId])!='undefined'){
			largeImgName = data[2][fileId].bigImgName;
			if(largeImgName!=''){
				result1 +="<div class='thumbnailimg'><a href="+prodImgPath+'/large/'+largeImgName+" class='MagicZoom' rel='zoom-id:Zoomer;'  rev="+prodImgPath+"/small/"+prodImage+"><img src="+prodImgPath+"/small/"+prodImage+" height='50' width='43' align='middle' ></a></div>";
				if(pFileId!=fileId){
					document.getElementById('productimagebig').innerHTML += '<a href='+prodImgPath+'/large/'+largeImgName+' title="'+$('#hidProductName').val()+'"></a>';
				}
			}
		}else{
			result1 +="<div class='thumbnailimg'><img src="+prodImgPath+"/small/"+prodImage+" height='50' width='43' align='middle' onmouseover=changeProductImage('"+prodImgPath+"','"+prodImage+"','','','') /></div>";
		}
	}
	//$(function(){$('.productimagebig a').lightBox();});
	$('#prodImages').html(result1);
	if (! $.browser.msie ){

		MagicZoom.refresh();
	}


	
	$('#addToCartBtn').css("display","block");
	$('#addToCartwait').css("display","none");

}










////////////////////////////////////







function changeProductImage(prodImgPath,prodImage,imageTitle,imageAlt){
	if(arguments[4]){
		document.getElementById("productimagebig").innerHTML = "<a rel='lightbox' title='"+document.getElementById("hidProductName").value+"' style='cursor:pointer;' href="+prodImgPath+"/large/"+arguments[4]+"><img src="+prodImgPath+"/small/"+prodImage+" height='300' width='300' align='middle' alt="+imageAlt+" title="+imageTitle+" style='cursor:pointer;' border='0'/></a>";

		imgNames = arguments[5].split(';');imgNames.pop();
		fileIds = arguments[6].split(';');fileIds.pop();
		fileId=arguments[7];

		for(var i in imgNames){
			if(fileId != fileIds[i])
			document.getElementById('productimagebig').innerHTML += '<a href='+prodImgPath+'/large/'+imgNames[i]+' title="'+document.getElementById("hidProductName").value+'"></a>';
		}
		//$(function() {$('.productimagebig a').lightBox();});

	}else
	document.getElementById("productimagebig").innerHTML = "<img src="+prodImgPath+"/small/"+prodImage+" height='300' width='300' align='middle' alt="+imageAlt+" title="+imageTitle+"/>";
}

function changeRatingImages(imgPos){
	var i=j=0;
	for(i=1;i<=imgPos;i++){
		$('#ratingImg_'+i).attr({src:"tl_files/img/5220.jpg"});
	}
	for(j=imgPos+1;j<=5;j++){
		$('#ratingImg_'+j).attr({src:"tl_files/img/5219.jpg"});
	}
	document.getElementById('hidCustomerRating').value = i-1;
}








function openReviewLayer(){
emailwindow = dhtmlmodal.open('EmailBox', 'div', 'productreview', alerts['1013'], 'width=425px,height=500px,center=1,resize=0,scrolling=0');
}


/* prod detail page  */

// search order with the criteria entered
function GeneralSearch( pType, e )
{

    var key;
    // if IE
    if (window.event){
        // catch the event
        e = window.event;
        key = e.keyCode;
    }else if(e.which){
        // netscape
        key = e.which;
    }
    // if key pressed is enter key
    if ( key == '13' ){
        showSearchResults(1);
        return false;
    }else{
        return true;
    }
}

/**
* This fuction is used to
* show all search  results
*
* @access   public
* @param    null
*
* @return   null
*/
function showSearchResults(startAt)
{
    if(document.getElementById("txtSearch").value.match(/^ *$/)){
		alert(alerts['1016']);
		document.getElementById("txtSearch").focus();
		return;
    }else if (document.getElementById("txtSearch").value ==document.getElementById("searchword").value){
        alert(alerts['1016']);
        document.getElementById("txtSearch").focus();
        return;
    }
	searchTxt=document.getElementById("txtSearch").value;
	//document.frmVivalite.action = "search_results.html?q="+searchTxt+"&p="+startAt;
    //location.replace("search_results.html?q="+searchTxt+"&p="+startAt)
	window.parent.location.replace("search_results.html?q="+searchTxt+"&p="+startAt)

}




noSearchResultSend = function(keyword){
	
	var a = parseInt(document.forms[0].searchrandom1.value);
	var b = parseInt(document.forms[0].searchrandom2.value);
	var sum = a + b;

	if(document.forms[0].emailId.value.match(/^ *$/)){
		//no email
		alert(alerts['1001']);
		document.forms[0].emailId.focus();
		return;
	}else if(!(validateEmail(document.forms[0].emailId.value))){
		//invalid email
		alert(alerts['1002']);
		document.forms[0].emailId.focus();
		return;
	}else if(document.forms[0].description.value.match(/^ *$/)){
		alert(alerts['1008']);
		document.forms[0].description.focus();
		return;
	}else if( sum != document.forms[0].searchsum.value){
		alert(alerts['1005']);
		document.forms[0].searchsum.focus();
		return;
	}

	mail_id = $('#emailId').val(),
	fname   = $('#firstName').val(),
	lname   =$('#lastName').val(),
	desc    = $('#description').val(),

	 $("#searchsendbutton").css('display','none');
	 $("#searchwaitbutton").css('display','block');
	
	


		$.getJSON(
		'search_results.html', //search module
			{
				mailid : mail_id,
				firstName : fname,
				lastName : lname,
				detailDesc : desc,
				searchedkeyword : keyword,
				hidSearchAction     : 'nosearchresult'
			},
			function (response,responsetext) {

			fadeinSendButton();
				 
			}
		);

}


function fadeinSendButton(){
	alert(alerts['1017']);
	 $("#searchsendbutton").css('display','block');
	 $("#searchwaitbutton").css('display','none');
	
	document.forms[0].emailId.value ='';
	document.forms[0].firstName.value = '';
	document.forms[0].lastName.value ='';
	document.forms[0].description.value ='';
	document.forms[0].searchsum.value='';

}

function fadeinCopySendButton(){
	alert(alerts['1017']);
	 $("#copyrightsend").css('display','block');
	 $("#copyrightwait").css('display','none');


		document.forms[0].copyemail.value ='';
		document.forms[0].emailconfirm.value ='';
		document.forms[0].publisher.value = '';
		document.forms[0].coverprice.value ='';
		document.forms[0].copyright_comment.value ='';
		document.forms[0].copydaysel.value='0';
		document.forms[0].copymonthsel.value='0';
		document.forms[0].copyyearsel.value='0';
		document.forms[0].copysum.value='';
}
function fadeinReturnSendButton(){
		alert(alerts['1017']);
		
		$("#returnsend").css('display','block');
		$("#returnwait").css('display','none');

		document.forms[0].returnEmail.value ='';
		document.forms[0].returnName.value = '';
		document.forms[0].returnPhone.value ='';
		document.forms[0].returnDate.value='0';
		document.forms[0].returnMonth.value='0';
		document.forms[0].returnYear.value='0';
		document.forms[0].returnOrderNo.value='';
		document.forms[0].returnReason.value='';
		document.forms[0].returnComment.value='';
		document.frmVivalite.returnPickup.checked=false;
}



/*****************copyright tpl****************/
openWindow = function(url){
	window.open(url);
}

copyrightSend = function(url){
	if(validateCopyright()){


		mediatype = $('#mediatype').val();
		mailid = $('#copyemail').val();
		copydaysel = $('#copydaysel').val();
		copymonthsel= $('#copymonthsel').val();
		copyyearsel = $('#copyyearsel').val();
		publisher = $('#publisher').val();
		coverprice = $('#coverprice').val();
		copyright_comment = $('#copyright_comment').val();



	$("#copyrightsend").css('display','none');
	 $("#copyrightwait").css('display','block');


		$.getJSON(
		'search_results.html', //search module
			{
				url_lookingfor : url,
				mediatype : mediatype,
				mailid : mailid,
				copydaysel : copydaysel,
				copymonthsel : copymonthsel,
				copyyearsel : copyyearsel,
				publisher : publisher,
				coverprice : coverprice,
				copyright_comment : copyright_comment,
				hidSearchAction     : 'copyrightmail'
			},
			function (response,responsetext) {

				fadeinCopySendButton();
				 
			}
		);

	}else{
		return false;
	}
}

validateCopyright = function(){
	var a = parseInt(document.forms[0].random1.value);
	var b = parseInt(document.forms[0].random2.value);
	var sum = a + b;

	if(document.forms[0].copyemail.value.match(/^ *$/)){
		//no email
		alert(alerts['1001']);
		document.forms[0].copyemail.focus();
		return false;
	}else if(!(validateEmail(document.forms[0].copyemail.value))){
		//invalid email
		alert(alerts['1002']);
		document.forms[0].copyemail.focus();
		return false;
	}else if(document.forms[0].emailconfirm.value.match(/^ *$/)){
		//no email
		alert(alerts['1018']);
		document.forms[0].emailconfirm.focus();
		return false;
	}else if(document.forms[0].copyemail.value != document.forms[0].emailconfirm.value){
		//email not match
		alert(alerts['1019']);
		document.forms[0].emailconfirm.focus();
		return false;
	}else if(document.forms[0].copydaysel.value == 0){
		//Day not selected
		alert(alerts['1020']);
		document.forms[0].copydaysel.focus();
		return false;
	}else if(document.forms[0].copymonthsel.value == 0){
		//month not selected
		alert(alerts['1021']);
		document.forms[0].copymonthsel.focus();
		return false;
	}else if(document.forms[0].copyyearsel.value == 0){
		//year not selected
		alert(alerts['1022']);
		document.forms[0].copyyearsel.focus();
		return false;
	}else if(document.forms[0].publisher.value.match(/^ *$/)){
		//no publisher
		alert(alerts['1023']);
		document.forms[0].publisher.focus();
		return false;
	}else if(document.forms[0].coverprice.value.match(/^ *$/)){
		//no coverprice
		alert(alerts['1024']);
		document.forms[0].coverprice.focus();
		return false;
	}else if(document.forms[0].copyright_comment.value.match(/^ *$/)){
		//no description
		alert(alerts['1025']);
		document.forms[0].copyright_comment.focus();
		return false;
	}else if( sum != document.forms[0].copysum.value){
		alert(alerts['1005']);
		document.forms[0].copysum.focus();
		return false;
	}else{
		return true;
	}
}




/**************returning orders*******************/
submitReturnOrders = function(){


	if(validateReturnOrders()){


		if(document.forms[0].returnILike[0].checked){
			returnILike = document.forms[0].returnILike[0].value;
		}else if(document.forms[0].returnILike[1].checked){
			returnILike = document.forms[0].returnILike[1].value;
		}else if(document.forms[0].returnILike[2].checked){
			returnILike = document.forms[0].returnILike[2].value;
		}
		var pickup =(document.forms[0].returnPickup.checked==true)?"y":"n";


		returnEmail = $('#returnEmail').val();
		returnName = $('#returnName').val();
		returnPhone= $('#returnPhone').val();
		returnDate = $('#returnDate').val();
		returnMonth = $('#returnMonth').val();
		returnYear = $('#returnYear').val();
		returnOrderNo = $('#returnOrderNo').val();
		returnReason = $('#returnReason').val();
		returnComment = $('#returnComment').val();


		$("#returnsend").css('display','none');
		$("#returnwait").css('display','block');

		
		
		//setTimeout("fadeinReturnSendButton()",2000);





		$.getJSON(
		'ajax.php?action=fmd&id=60', //returning order module
			{
				returnILike : returnILike,
				returnEmail :returnEmail,
				returnName: returnName,
				returnPhone: returnPhone,
				returnDate : returnDate,
				returnMonth : returnMonth,
				returnYear :returnYear,
				returnOrderNo : returnOrderNo,
				returnReason: returnReason,
				returnComment: returnComment,
				returnMailTo : $('#returnMailTo').val(),
				returnPickup : pickup,
				hidAction     : 'sendreorder'
			},
			function (response,responsetext) {

				fadeinReturnSendButton();
				 
			}
		);

	}else{
		return false;
	}


}

validateReturnOrders = function(){
	if( document.frmVivalite.returnEmail.value.match(/^ *$/)){
		//no email
		alert(alerts['1001']);
		document.frmVivalite.returnEmail.focus();
		return false;
	}else if(!(validateEmail(document.frmVivalite.returnEmail.value))){
		//invalid email
		alert(alerts['1002']);
		document.frmVivalite.returnEmail.focus();
		return false;
	}else if( document.frmVivalite.returnName.value.match(/^ *$/)){
		//no email
		alert(alerts['1014']);
		document.frmVivalite.returnName.focus();
		return false;
	}else if( document.frmVivalite.returnPhone.value.match(/^ *$/)){
		//no email
		alert(alerts['1026']);
		document.frmVivalite.returnPhone.focus();
		return false;
	}else if((document.frmVivalite.returnOrderNo.value.match(/^ *$/)) && (document.forms[0].returnDate.value == 0) && (document.forms[0].returnMonth.value == 0 && (document.forms[0].returnYear.value == 0))){
		//no email
		alert(alerts['1027']);
		document.frmVivalite.returnOrderNo.focus();
		return false;
	}else if((document.forms[0].returnDate.value == 0) && (document.frmVivalite.returnOrderNo.value.match(/^ *$/))){
		//Day not selected
		alert(alerts['1020']);
		document.forms[0].returnDate.focus();
		return false;
	}else if((document.forms[0].returnMonth.value == 0 ) && (document.frmVivalite.returnOrderNo.value.match(/^ *$/))){
		//month not selected
		alert(alerts['1021']);
		document.forms[0].returnMonth.focus();
		return false;
	}else if((document.forms[0].returnYear.value == 0) && (document.frmVivalite.returnOrderNo.value.match(/^ *$/))){
		//year not selected
		alert(alerts['1022']);
		document.forms[0].returnYear.focus();
		return false;
	}else
		return true;
}


// to continue order w r t the login type selected
function continueOrder()
{ 

	var path = document.referrer;
	var pos = path.lastIndexOf("/");
	pos++;
	var url = path.substr(pos);
	if(pos==path.length && url=='')
		url = 'home.html';



	if (document.getElementById("loginnewaccount").checked) {


		if(document.getElementById("newuser_login").value.match(/^ *$/)){
			alert(alerts['1001']);
			document.getElementById("newuser_login").focus();
			return;
		}
		if(!(validateEmail(document.getElementById("newuser_login").value))){
			alert(alerts['1002']);
			document.getElementById("newuser_login").focus();
			return;
		}	



		$.getJSON(
				'enter.html', 
					{
						newuserName : document.getElementById("newuser_login").value,
						mewpassWord : document.getElementById("newwser_password").value,
						hidAction   : 'checkloginexists'
					},
					function (response,responsetext) {


						if(response=='exists'){

							document.getElementById('loginidexists').style.display = '';
							return false;


						}else{

								if(document.getElementById("newwser_password").value.match(/^ *$/)){
									alert(alerts['1028']);
									document.getElementById("newwser_password").focus();
									return;
								}


							if(url == 'shopping_cart.html'){
								window.parent.location ="checkout_account.html?custom="+getCookie($("#hidPHPSessionName").val());
							}else{
								window.parent.location ="create_account.html?custom="+getCookie($("#hidPHPSessionName").val());
							}
						
						}
					}
			); 




	}else if (document.getElementById("loginoldaccount").checked){

		if(document.getElementById("user_login").value.match(/^ *$/)){
			alert(alerts['1001']);
			document.getElementById("user_login").focus();
			return;
		}
		if(!(validateEmail(document.getElementById("user_login").value))){
			alert(alerts['1002']);
			document.getElementById("user_login").focus();
			return;
		}	
		if(document.getElementById("user_password").value.match(/^ *$/)){
			alert(alerts['1028']);
			document.getElementById("user_password").focus();
			return;
		}
		//check username and password are correct
		checkLogin('layer');
	}else if(document.getElementById("loginwithoutaccount").checked){


		$.getJSON(
				'enter.html', 
					{
						hidAction   : 'noaccount'
					},
					function (response,responsetext) {

						window.parent.location ="checkout_account.html?custom="+getCookie($("#hidPHPSessionName").val());
						
					}
			); 
	}


}







// to show the display of login and password
function showDisplayLogin1()
{
	document.getElementById("newaccount").style.display = '';
	document.getElementById("accountalready").style.display = 'none';
}
// to show the display of login and password
function showDisplayLogin2()
{
	document.getElementById("accountalready").style.display = '';
	document.getElementById("newaccount").style.display = 'none';

}

// to hide the display of login and password
function hideDisplayLogin()
{
	document.getElementById("accountalready").style.display = 'none';
	document.getElementById("newaccount").style.display = 'none';
} 


//hide message
clearMessage = function(){
	document.getElementById('incorrectLogin').style.visibility = 'hidden';
}

// function to catch enter key event.eis event and functionName is the name of function which should be called when enter key pressed
function catchEnterKey(e,functionName)
{
    var key;
	// if IE
    if (window.event){
		// catch the event
        e = window.event;
		key = e.keyCode;
    }else if(e.which){
		// netscape
		key = e.which; 
	}
	// if key pressed is enter key
	if ( key == '13' ){
		//continueOrder();
		eval(functionName)();
	}
}


function checkLogin(from){

	var path = document.referrer;
	var pos = path.lastIndexOf("/");
	pos++;
	var url = path.substr(pos);

	var userName = $('#user_login').val();
	var passWord = $('#user_password').val();
			$.getJSON(
				'enter.html', // login module since we use iframe, we can give as enter.html or window.location.pathname
					{
						userName : userName,
						passWord : passWord,
						hidAction   : 'checklogin'
					},
					function (response,responsetext) {
						if(response == 'denied') {

							if(from=='home'){

								alert(alerts['1066']);
								return false;
							}else{
								document.getElementById('incorrectLogin').style.visibility = 'visible';
							}

						}  else if(response['prodcount'] >0) { // if items in cart
							window.parent.location= "http://"+response['domain']+"/checkout_account.html?custom="+getCookie($("#hidPHPSessionName").val());
							


						}else{  // if no  items in cart
							window.parent.location= "http://"+response['domain']+"/my_account.html?custom="+getCookie($("#hidPHPSessionName").val());


					}
					}
			); 



}



requestPassword = function()
{
	emailId = document.getElementById('forgotPasswdEmail').value;

	if(document.getElementById("forgotPasswdEmail").value.match(/^ *$/)){
			alert(alerts['1001']);
			document.getElementById("forgotPasswdEmail").focus();
			return;
	}

	if(!(validateEmail(emailId))){
		alert(alerts['1002']);
		document.getElementById('forgotPasswdEmail').focus();
		return false;
	}


	$('#pwdforgotrequest').css("display","none");
	$('#pwdforgotwait').css("display","block");

	$.getJSON(
				'enter.html', // login module
					{
						forgotPasswdEmail : emailId,
						hidAction   : 'requestPassword'
					},
					function (response,responsetext) {
						$('#pwdforgotrequest').css("display","block");
						$('#pwdforgotwait').css("display","none");

						switch(response){
							case 'mailsendSuccess':
								document.getElementById('mailsendSuccess').style.display = 'block';
								document.getElementById('mailsendFailed').style.display = 'none';
								document.getElementById('emailIdNotExist').style.display = 'none';
								document.getElementById('forgotPasswdEmail').value=''
							break;
							case 'mailsendFailed':
								document.getElementById('mailsendSuccess').style.display = 'none';
								document.getElementById('mailsendFailed').style.display = 'block';
								document.getElementById('emailIdNotExist').style.display = 'none';
							break;
							case 'emailIdNotExist':
								document.getElementById('mailsendSuccess').style.display = 'none';
								document.getElementById('mailsendFailed').style.display = 'none';
								document.getElementById('emailIdNotExist').style.display = 'block';
							break;
							default:
							break;
						}
					}
			); 


}



  searchOrder = function() {
	  $.getJSON(
		window.location.pathname,
			{
				searchString : $('#orderSearch').val(),
				hidAction     : 'SearchOrder'
			},
			function (response,responsetext) {
				location.reload();
				//window.location= "my_account.html#orders";
			}
	  );
  }



  checkLoginId = function(login) {

	  if(login==''){
		return false;
	}
	  $.getJSON(
		'ajax.php?action=fmd&id=42',
			{
				login : login,
				hidAction       : 'checkLoginId'
			},
			function (response,responsetext) {
				if(response=='exists'){
					document.getElementById('loginExistMsg').style.display = 'block';
					document.getElementById('email').focus();
				}else{
					document.getElementById('loginExistMsg').style.display = 'none';
				}
			}
	  );
  }


function changePage(pageIndex)
{
    document.getElementById("hidPageIndex").value = pageIndex;
    document.getElementById("hidSortOrder").value = document.getElementById("prodlistorder").value;
    document.getElementById("frmVivalite").submit();
}


function changeDelCountry(host,currentcnty){

	cntyid   = $('#deliverycountry :selected').attr('countryid');

	if(document.getElementById('hidLoggedValue').value=='1' ) {

			msg = alerts['1080'];

			countryname   = $('#deliverycountry :selected').html();

			from  = document.getElementById('hidSelectedCountryName').value;
			to  = countryname;
			to = to.replace(/^\s\s*/, '').replace(/\s\s*$/, '');

			msg = msg.replace('FROM_COUNTRY', from);

			msg = msg.replace(/TO_COUNTRY/g, to);

			$("select[name='deliverycountry'] option[countryid="+currentcnty+"]").attr("selected", true);

			alert(msg);
			return false;
	}

		
	cntdomain = document.getElementById("deliverycountry").value;



	if(cntyid !=currentcnty){

			if(cntdomain==host){
				document.getElementById("hidValCountryAction").value='changecountry';
				document.getElementById("hidValCountryId").value=cntyid;
				document.getElementById("frmVivalite").submit();
			}else{

				$.getJSON(
				'shopping_cart.html', 
					{
						countryval  : cntyid,
						cntdomain  : cntdomain,
						hidValPage  : 'cart',
						hidAction : 'savecountry'

					},
					function (response,responsetext) {

						window.location= "http://"+cntdomain+"/shopping_cart.html?custom="+getCookie($("#hidPHPSessionName").val())+'&item='+response;

					}
			     ); 


			}
	}
}


var prd_min_qty_arr = new Array();
function MinOrderQtyInfo(sc_id, min_qty)
{
	prd_min_qty_arr[sc_id] = min_qty ;
}


// 
// increments the quantity
//

function IncrementCart(cartindx)
{
	var qty = document.getElementById("cartprodquantity_"+cartindx).value;
	document.getElementById("cartprodquantity_"+cartindx).value= qty*1+1;
	
	document.getElementById("hidCartIndx").value =cartindx;
	document.getElementById("hidCartQty").value =qty*1+1;
	document.getElementById("hidAction").value ="updateqty";


	$.getJSON(window.location.pathname,{hidAction: "updateqty",hidCartIndx:cartindx,hidCartQty:qty*1+1}, function(data) {
			HttpCartQtyUpdate(data,cartindx)
	});

	return;
}


function HttpCartQtyUpdate(data,cartindx){
     price= data['currsymbol']+' '+data['totalamt'];

	document.getElementById("cartamtnav").innerHTML    = price;

	document.getElementById("prodprice_"+cartindx).innerHTML =  data['prodPrice'];
	document.getElementById("carttotalamount").innerHTML    = data['totalamt'];
	document.getElementById("carttotalamount").innerHTML    = data['totalamt'];
	document.getElementById("carttotalamounttax").innerHTML = data['totaltax'];
	document.getElementById("subtotal_"+cartindx).innerHTML = data['subtotal'];
	document.getElementById("subtotaltax_"+cartindx).innerHTML = data['subtotaltax'];

	document.getElementById("hidTotalCostWithoutDelim").value = data['totalamtwithoutdelim'];

	document.getElementById("cartshipcost").innerHTML   = data['shipcost'];
	document.getElementById("cartshiptax").innerHTML    = data['shiptax'];
}

// 
// decrements the quantity
//
function DecrementCart(cartindx,prodname,minqty)
{

	var qty1 = document.getElementById("cartprodquantity_"+cartindx).value;

	// decrement until it reaches min quantity
	if(  prd_min_qty_arr[cartindx] <= qty1*1-1 ) {
		document.getElementById("cartprodquantity_"+cartindx).value= qty1*1-1;


		$.getJSON(window.location.pathname,{hidAction: "updateqty",hidCartIndx:cartindx,hidCartQty:qty1*1-1}, function(data) {
				HttpCartQtyUpdate(data,cartindx)
		});


	}else{


			alert(alerts['1039']+ ' '+prodname+' '+alerts['1040']+ ' '+minqty  );

	}	

	

	return;

}


function deleteCartItem(cartindx){

		flag= window.confirm(alerts['1045']);

		if(flag){
			$.getJSON(window.location.pathname,{hidAction: "deletecart",hidCartIndx:cartindx}, function(data) {
					window.location.reload();
			});
		}

}

function updateCartQuantity(cartindx,val,prodname,minqty){




		if(!validateQuantity(cartindx,val,prodname,minqty)){

			return false;
		}

		$.getJSON(window.location.pathname,{hidAction: "updateqty",hidCartIndx:cartindx,hidCartQty:val}, function(data) {
				HttpCartQtyUpdate(data,cartindx)
		});
}




function validateQuantity(cartindx,val,prodname,minqty)
{

	if(val*1 < minqty*1){
		alert(alerts['1039']+ ' '+prodname+' '+alerts['1040']+ ' '+minqty  );
		document.getElementById('cartprodquantity_'+cartindx).value=minqty;
		updateCartQuantity(cartindx,minqty,prodname,minqty);
		return false;

	}	
	
	if(isNaN(val) || val.match(/\.+/) || val == '' || val < 1){
		alert(alerts['1012']);
		document.getElementById('cartprodquantity_'+cartindx).value=minqty;
		updateCartQuantity(cartindx,minqty,prodname,minqty);

		return false;
	}
	return true;
}



function validateProdQuantity(value,prodname,minqty)
{
	if(value*1 < minqty*1){
		alert(alerts['1039']+ ' '+prodname+' '+alerts['1040']+ ' '+minqty  );
		document.getElementById('prodQty').value=minqty;
		return false;

	}	
	
	if(isNaN(value) || value.match(/\.+/) || value == '' || value < 1){
		alert(alerts['1012']);
		document.getElementById('prodQty').value=minqty;
		return false;
	}
	return true;
}





function changeCartProdOption(val,cartindx){

	qty = $('#cartprodquantity_'+cartindx).val();

	$.getJSON(window.location.pathname,{hidAction: "changeoption",hidCartIndx:cartindx,hidCartProdOptId:val,hidCartQty:qty}, function(data) {
			HttpCartOptionChange(data,cartindx)
	});
}




function HttpCartOptionChange(data,cartindx){

	if(data['prodexists']=='true'){

		for(i=1;i<=6;i++){
			$('#'+i+'_cart_tr_'+data['existingcartindx']).fadeOut(1000,function(){
				$('#'+i+'_cart_tr_'+data['existingcartindx']).css("display","none");

			});
		}

		$('#cartprodquantity_'+cartindx).val(data['totalqty']);
	}
    price= data['currsymbol']+' '+data['totalamt'];
	document.getElementById("cartamtnav").innerHTML    = price;
	document.getElementById("carttotalamount").innerHTML    = data['totalamt'];
	document.getElementById("carttotalamounttax").innerHTML = data['totaltax'];
	document.getElementById("subtotal_"+cartindx).innerHTML = data['subtotal'];
	document.getElementById("subtotaltax_"+cartindx).innerHTML = data['subtotaltax'];
	document.getElementById("prodprice_"+cartindx).innerHTML = data['price'];
	document.getElementById("proditemno_"+cartindx).innerHTML = data['itemno'];
	document.getElementById("hidTotalCostWithoutDelim").value = data['totalamtwithoutdelim'];

	document.getElementById("cartshipcost").innerHTML   = data['shipcost'];
	document.getElementById("cartshiptax").innerHTML    = data['shiptax'];


	stockhandling = data['stockhandling'];
	stockstatus   = data['stockstatus'];
	imagename     = data['imagename'];
	path          = data['imagepath'];

	img ="<img src="+path+"/small/"+imagename+" height='50' width='50' >";

	document.getElementById("prodimage_"+cartindx).innerHTML = img;




		greenmsg  = document.getElementById("hidStockGreenMsg").value;
		yellowmsg = document.getElementById("hidStockYellowMsg").value;
		redmsg    = document.getElementById("hidStockRedMsg").value;

		if(stockhandling == 'm' && stockstatus =='y' ){
			$("#stockstatusimage_"+cartindx).css('color','orange');
			$("#stockstatusimage_"+cartindx).html(yellowmsg);
		}else if(stockhandling == 'm' && stockstatus =='r'){
			$("#stockstatusimage_"+cartindx).css('color','red');
			$("#stockstatusimage_"+cartindx).html(redmsg);
		}else{
			$("#stockstatusimage_"+cartindx).css('color','green');
			$("#stockstatusimage_"+cartindx).html(greenmsg);

		}

}



function openCurrencyLayer(){
	currencylayer = layermodal.open('EmailBox', 'div', 'currencyConverterlayer', alerts['1078'], 'width=425px,height=180px,center=1,resize=0,scrolling=0');

	document.getElementById("originalcartval").innerHTML =document.getElementById("carttotalamount").innerHTML;
	document.getElementById("convertedcurrvalue").innerHTML =document.getElementById("carttotalamount").innerHTML;

}

function CloseCurrLayer(){

	layermodal.close(currencylayer);

}


function convertCurrency(from){


	if(document.getElementById("changecurrency").value =='0'){

		alert(alerts['1042']);

		return false;
	}

	to= document.getElementById("changecurrency").value
	cost= document.getElementById("hidTotalCostWithoutDelim").value

	$.getJSON(window.location.pathname,{hidAction: "changecurr",hidFromCurrency:from,hidToCurrency:to,hidTotalCostWithoutDelim:cost}, function(data) {

			document.getElementById("convertedcurrshort1").innerHTML  = data['shortname'];
			document.getElementById("convertedcurrshort2").innerHTML  = data['shortname'];
			document.getElementById("convertedcurrvalue").innerHTML   = data['convertedprice'];

			
	});
}

	function openLoginLayer(){

		 loginlayer = layermodal.open('LoginBox', 'div', 'SecuredLoginPage', alerts['1079'], 'width=675px,height=235px,center=1,resize=0,scrolling=0');
		
		 setTimeout('closeLogin()',5000);
	}



function closeLogin(){


	$('#loginframeid').contents().find("#closelogin").click(function(){

		$('#LoginBox').hide();
	});

}



function makeAddressDisplay(){

	if(document.getElementById("addresscheckbox").checked){
		document.getElementById("invoiceaddress").style.display ='none';
		document.getElementById("invoiceemaildiv").style.display ='';
		document.getElementById("invoiceemailspacediv").style.display ='';

	}else{
		document.getElementById("invoiceaddress").style.display ='';
		document.getElementById("invoiceemaildiv").style.display ='none';
		document.getElementById("invoiceemailspacediv").style.display ='none';
	}



}



	 UpdateMyAccount= function(host) {

		 if(document.getElementById("hidCreateAccount").value=='y' || document.getElementById("hidCreateAccount").value=='n'){

			 createMyAccount(host)
			 return;
		 }
		 if(document.getElementById("createprivateaccount").style.display==''){
			 custtype='b'
		 }else{
			 custtype='c'
		 }

		if(document.getElementById('addresscheckbox').checked){
			sameDelAdd = 'y';//invoice and delivery address same

			var phoneCntry     = $('#phoneCntry').val();
			var phoneArea      =$('#phoneArea').val();
			var phoneNo        = $('#phoneNo').val();

			var invStreet	   = $('#shipStreet').val();
			var invAdditional  = $('#shipAdditional').val();
			var invZip		   = $('#shipZip').val();
			var invCity		   = $('#shipCity').val();
			var invCntry       = $('#shipCountry').val();
			var invRegion	   = $('#shipRegion').val();
			var fname		   = $('#delfname').val();
			var lname		   = $('#dellname').val();
			var invCountryName	= document.forms[0].shipCountry.options[document.forms[0].shipCountry.options.selectedIndex].text;


			/*if(document.frmVivalite.shipGender[0].checked){
				invgender = document.frmVivalite.shipGender[0].value;
			}else if(document.frmVivalite.shipGender[1].checked){
				invgender = document.frmVivalite.shipGender[1].value;
			}else if(document.frmVivalite.shipGender[2].checked){
				invgender = document.frmVivalite.shipGender[2].value;
			}*/

			invgender = $('span input[name=shipGender]:checked').val()



		}else{
			sameDelAdd         = 'n';
			var phoneCntry     = $('#invphoneCntry').val();
			var phoneArea      = $('#invphoneArea').val();
			var phoneNo        = $('#invphoneNo').val();

			var invStreet	   = $('#invStreet').val();
			var invAdditional  = $('#invAdditional').val();
			var invZip		   = $('#invZip').val();
			var invCity		   = $('#invCity').val();
			var invCntry       = $('#invCntry').val();
			var invRegion	   = $('#invRegion').val();
			var fname		   = $('#fname').val();
			var lname		   = $('#lname').val();
			var invCountryName	= document.forms[0].invCntry.options[document.forms[0].invCntry.options.selectedIndex].text;
			
			/*if(document.frmVivalite.invGender[0].checked){
				invgender = document.frmVivalite.invGender[0].value;
			}else if(document.frmVivalite.invGender[1].checked){
				invgender = document.frmVivalite.invGender[1].value;
			}else if(document.frmVivalite.invGender[2].checked){
				invgender = document.frmVivalite.invGender[2].value;
			}*/

			invgender = $('span input[name=invGender]:checked').val()

		}

		/*if(document.frmVivalite.shipGender[0].checked){
			shipgender = document.frmVivalite.shipGender[0].value;
		}else if(document.frmVivalite.shipGender[1].checked){
			shipgender = document.frmVivalite.shipGender[1].value;
		}else if(document.frmVivalite.shipGender[2].checked){
			shipgender = document.frmVivalite.shipGender[2].value;
		}*/

		shipgender = $('span input[name=shipGender]:checked').val()



		
		var shipfname	   = $('#delfname').val();
		var shiplname	   = $('#dellname').val();
		var companyname    = $('#companyname').val();
		var vatid          = $('#vatid').val();
		var shipStreet	   = $('#shipStreet').val();
		var shipAdditional = $('#shipAdditional').val();
		var shipZip		   = $('#shipZip').val();
		var shipCity	   = $('#shipCity').val();
		var shipCountry    = $('#shipCountry').val();
		var shipRegion     = $('#shipRegion').val();
		var oldPasswd      = $('#oldPasswd').val();
		var newPasswd      = $('#newPasswd').val();
		var sameAdd        =   sameDelAdd;
		var invAddIndx     = $('#hidValInvAddIndx').val();
		var shipAddIndx    = $('#hidValShipAddIndx').val();
		var phoneIndx      = $('#hidValPhoneIndx').val();
		var emailIndx      = $('#hidValEmailIdIndx').val();
		var email		   = $('#email').val();
		var shipCountryName	= document.forms[0].shipCountry.options[document.forms[0].shipCountry.options.selectedIndex].text;



		if(!validateMyAccountDetails(sameDelAdd)) {
			return false;
		}

		$('#checkoutaccountbutton').css("display","none");
		$('#checkoutaccountwait').css("display","block");
		
		var path = window.location.pathname;
		var pos = path.lastIndexOf("/");
		pos++;
		var url = path.substr(pos);
		

		$.getJSON(
			window.location.pathname,
				{
					gender		   : invgender,
					shipgender	   : shipgender,
					fname		   : fname,
					lname		   : lname,
					shipfname		: shipfname,
					shiplname		: shiplname,
					companyname	   : companyname,
					vatid	       : vatid,
					phoneCntry	   : phoneCntry,
					phoneArea	   : phoneArea,
					phoneNo		   : phoneNo,
					email		   : email,
					invStreet	   : invStreet,
					invAdditional  : invAdditional,
					invZip		   : invZip,
					invCity		   : invCity,
					invCntry	   : invCntry,
					invCountryName	   : invCountryName,
					invRegion	   : invRegion,
					shipStreet	   : shipStreet,
					shipAdditional : shipAdditional,
					shipZip		   : shipZip,
					shipCity	   : shipCity,
					shipCountry	   : shipCountry,
					shipCountryName	   : shipCountryName,
					shipRegion	   : shipRegion,
					sameAdd		   : sameAdd,
					invAddIndx	   : invAddIndx,
					shipAddIndx	   : shipAddIndx,
					phoneIndx	   : phoneIndx,
					newPasswd	   : newPasswd,
					custtype	   : custtype,
					hidAction    : 'UpdateAccount'
				},

				function (response,responsetext) {

					if(url=='my_account.html'){
						//location.reload();

						if(host==response){
							location.reload();
						}else{
							window.location= "http://"+response+"/my_account.html?custom="+getCookie($("#hidPHPSessionName").val());
						}


					}	else{
						window.location= "checkout_shipping.html";
					}

				}
		);  		



  }




      validateMyAccountDetails = function(sameDelAdd){

		
		  if( document.getElementById("hidCustomerType").value=="b" ||  document.getElementById("createprivateaccount").style.display==''){


			if( document.forms[0].companyname.value.match(/^ *$/)){
				document.getElementById("entryerrormessage").style.display='';
				document.getElementById("errorid_comp_vat").style.visibility='visible';
				document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];
				document.forms[0].companyname.focus();
				return false;
			}
		}




		if( !document.forms[0].shipGender[0].checked &&  !document.forms[0].shipGender[1].checked && !document.forms[0].shipGender[2].checked ){
				document.getElementById("entryerrormessage").style.display='';
				document.getElementById("respectiveerrormessage").innerHTML  = alerts['1044'];
				return false;
		}else if( document.forms[0].delfname.value.match(/^ *$/)){
			document.getElementById("entryerrormessage").style.display='';
			document.getElementById("errorid_name").style.visibility='visible';
			document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];

			document.getElementById("errorid_comp_vat").style.visibility='hidden';

			document.forms[0].delfname.focus();
			return false;
		}else if( document.forms[0].dellname.value.match(/^ *$/)){
			document.getElementById("entryerrormessage").style.display='';
			document.getElementById("errorid_name").style.visibility='visible';

			document.getElementById("errorid_comp_vat").style.visibility='hidden';
			document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];
			document.forms[0].dellname.focus();
			return false;
		}else if( document.forms[0].shipStreet.value.match(/^ *$/)){
			document.getElementById("entryerrormessage").style.display='';
			document.getElementById("errorid_street_add").style.visibility='visible';

			document.getElementById("errorid_name").style.visibility='hidden';
			document.getElementById("errorid_comp_vat").style.visibility='hidden';
			
			document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];
			document.forms[0].shipStreet.focus();
			return false;
		}else if( document.forms[0].shipCity.value.match(/^ *$/)){
			document.getElementById("entryerrormessage").style.display='';
			document.getElementById("errorid_city_zip").style.visibility='visible';
			document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];

			document.getElementById("errorid_name").style.visibility='hidden';
			document.getElementById("errorid_street_add").style.visibility='hidden';
			document.getElementById("errorid_comp_vat").style.visibility='hidden';

			document.forms[0].shipCity.focus();
			return false;
		}else if( document.forms[0].shipZip.value.match(/^ *$/)){
			document.getElementById("entryerrormessage").style.display='';
			document.getElementById("errorid_city_zip").style.visibility='visible';
			document.getElementById("respectiveerrormessage").innerHTML  = alerts['1043'];

			document.getElementById("errorid_name").style.visibility='hidden';
			document.getElementById("errorid_street_add").style.visibility='hidden';
			document.getElementById("errorid_comp_vat").style.visibility='hidden';

			document.forms[0].shipZip.focus();
			return false;
		}
		
		
	if( sameDelAdd=='y'){
			if( document.forms[0].email.value.match(/^ *$/)){
				document.getElementById("entryerrormessage").style.display='';
				document.getElementById("errorid_phone").style.visibility='visible';
				document.getElementById("respectiveerrormessage").innerHTML  = alerts['1001'];

				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_comp_vat").style.visibility='hidden';

				document.forms[0].email.focus();
				return false;
			}else if(!(validateEmail(document.getElementById("email").value))){

				document.getElementById("entryerrormessage").style.display='';
				document.getElementById("errorid_phone").style.visibility='visible';
				document.getElementById("respectiveerrormessage").innerHTML  = alerts['1002'];

				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_comp_vat").style.visibility='hidden';

				document.forms[0].email.focus();
				return false;
			}
	}






		if(sameDelAdd=='n'){

			document.getElementById("entryerrormessage").style.display='none';

			//invoice and delivery address diff. Validate delivery address also
			if( !document.forms[0].invGender[0].checked &&  !document.forms[0].invGender[1].checked && !document.forms[0].invGender[2].checked ){
				document.getElementById("entryerrormessage1").style.display='';
			
				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';

				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1044'];
				return false;
			}else if( document.forms[0].fname.value.match(/^ *$/)){
				document.getElementById("entryerrormessage1").style.display='';
				document.getElementById("errorid_inv_name").style.visibility='visible';
				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1043'];
			
				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';

				document.forms[0].fname.focus();
				return false;
		  }else if( document.forms[0].lname.value.match(/^ *$/)){
				document.getElementById("entryerrormessage1").style.display='';
				document.getElementById("errorid_inv_name").style.visibility='visible';
			    
				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1043'];
				document.forms[0].lname.focus();
				return false;
		  }else if( document.forms[0].invStreet.value.match(/^ *$/)){
				document.getElementById("entryerrormessage1").style.display='';
				document.getElementById("errorid_inv_street").style.visibility='visible';
				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1043'];
				
				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_inv_name").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
				document.forms[0].invStreet.focus();
				return false;
		  }else if( document.forms[0].invCity.value.match(/^ *$/)){
				document.getElementById("entryerrormessage1").style.display='';
				document.getElementById("errorid_inv_city_zip").style.visibility='visible';
				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1043'];

				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_inv_name").style.visibility='hidden';
				document.getElementById("errorid_inv_street").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
				document.forms[0].invCity.focus();
				return false;
		  }else if( document.forms[0].invZip.value.match(/^ *$/)){
				document.getElementById("entryerrormessage1").style.display='';
				document.getElementById("errorid_inv_city_zip").style.visibility='visible';
				document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1043'];

				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_inv_name").style.visibility='hidden';
				document.getElementById("errorid_inv_street").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
				document.forms[0].invZip.focus();
				return false;
		  }else if( document.forms[0].invemail.value.match(/^ *$/)){
			document.getElementById("entryerrormessage1").style.display='';
			document.getElementById("errorid_inv_phone").style.visibility='visible';
			document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1001'];

				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_inv_name").style.visibility='hidden';
				document.getElementById("errorid_inv_street").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
			document.forms[0].invemail.focus();
			return false;
		}else if(!(validateEmail(document.getElementById("invemail").value))){

			document.getElementById("entryerrormessage1").style.display='';
			document.getElementById("errorid_inv_phone").style.visibility='visible';
			document.getElementById("respectiveerrormessage1").innerHTML  = alerts['1002'];

				document.getElementById("errorid_comp_vat").style.visibility='hidden';
				document.getElementById("errorid_name").style.visibility='hidden';
				document.getElementById("errorid_street_add").style.visibility='hidden';
				document.getElementById("errorid_city_zip").style.visibility='hidden';
				document.getElementById("errorid_inv_name").style.visibility='hidden';
				document.getElementById("errorid_inv_street").style.visibility='hidden';
				document.getElementById("errorid_phone").style.visibility='hidden';
			document.forms[0].invemail.focus();
			return false;
		}
		  
		 
	}
	

		$('#accountbutton').css("display","none");
		$('#accountwait').css("display","block");



	
	return true;
}


function createPrivateAccount(){

	document.getElementById("bizaccount").style.display='none';
	document.getElementById("createprivateaccount").style.display='none';
	document.getElementById("createbizaccount").style.display='';

}
function createBizAccount(){

	document.getElementById("bizaccount").style.display='';
	document.getElementById("createprivateaccount").style.display='';
	document.getElementById("createbizaccount").style.display='none';

}

function createMyAccount(host){


		var path = window.location.pathname;
		var pos = path.lastIndexOf("/");
		pos++;
		var url = path.substr(pos);
		if(pos==path.length && url=='')
			url = 'home.html';


		if(document.getElementById('addresscheckbox').checked){
			sameDelAdd = 'y';//invoice and delivery address same

			var phoneCntry     = $('#phoneCntry').val();
			var phoneArea      =$('#phoneArea').val();
			var phoneNo        = $('#phoneNo').val();

			var invStreet	   = $('#shipStreet').val();
			var invAdditional  = $('#shipAdditional').val();
			var invZip		   = $('#shipZip').val();
			var invCity		   = $('#shipCity').val();
			var invCntry       = $('#shipCountry').val();
			var invRegion	   = $('#shipRegion').val();
			var fname		   = $('#delfname').val();
			var lname		   = $('#dellname').val();
			var lname		   = $('#dellname').val();
			var email		   = $('#email').val();
			var invCountryName	= document.forms[0].shipCountry.options[document.forms[0].shipCountry.options.selectedIndex].text;


			/*if(document.frmVivalite.shipGender[0].checked){
				invgender = document.frmVivalite.shipGender[0].value;
			}else if(document.frmVivalite.shipGender[1].checked){
				invgender = document.frmVivalite.shipGender[1].value;
			}else if(document.frmVivalite.shipGender[2].checked){
				invgender = document.frmVivalite.shipGender[2].value;
			}*/

			invgender = $('span input[name=shipGender]:checked').val()






		}else{
			sameDelAdd         = 'n';
			var phoneCntry     = $('#invphoneCntry').val();
			var phoneArea      = $('#invphoneArea').val();
			var phoneNo        = $('#invphoneNo').val();

			var invStreet	   = $('#invStreet').val();
			var invAdditional  = $('#invAdditional').val();
			var invZip		   = $('#invZip').val();
			var invCity		   = $('#invCity').val();
			var invCntry       = $('#invCntry').val();
			var invRegion	   = $('#invRegion').val();
			var fname		   = $('#fname').val();
			var lname		   = $('#lname').val();
			var email		   = $('#invemail').val();
			var invCountryName	= document.forms[0].invCntry.options[document.forms[0].invCntry.options.selectedIndex].text;

			
			/*if(document.frmVivalite.invGender[0].checked){
				invgender = document.frmVivalite.invGender[0].value;
			}else if(document.frmVivalite.invGender[1].checked){
				invgender = document.frmVivalite.invGender[1].value;
			}else if(document.frmVivalite.invGender[2].checked){
				invgender = document.frmVivalite.invGender[2].value;
			}*/

			invgender = $('span input[name=invGender]:checked').val()

		}



		/*if(document.frmVivalite.shipGender[0].checked){
			shipgender = document.frmVivalite.shipGender[0].value;
		}else if(document.frmVivalite.shipGender[1].checked){
			shipgender = document.frmVivalite.shipGender[1].value;
		}else if(document.frmVivalite.shipGender[2].checked){
			shipgender = document.frmVivalite.shipGender[2].value;
		}*/

		shipgender = $('span input[name=shipGender]:checked').val()


		if(document.getElementById("createprivateaccount").style.display==''){

			 custtype='b'
			
		 }else{
			 custtype='c'

		 }



		
		var shipfname	   = $('#delfname').val();
		var shiplname	   = $('#dellname').val();
		var companyname    = $('#companyname').val();
		var vatid          = $('#vatid').val();
		var shipStreet	   = $('#shipStreet').val();
		var shipAdditional = $('#shipAdditional').val();
		var shipZip		   = $('#shipZip').val();
		var shipCity	   = $('#shipCity').val();
		var shipCountry    = $('#shipCountry').val();
		var shipRegion     = $('#shipRegion').val();
		var newPasswd      = $('#hidNewUserPwd').val();
		var sameAdd        =   sameDelAdd;
		var shipCountryName	= document.forms[0].shipCountry.options[document.forms[0].shipCountry.options.selectedIndex].text;
		
		if(!validateMyAccountDetails(sameDelAdd)) {
			return false;
		}
		


		$.getJSON(
			window.location.pathname,
				{
					gender		   : invgender,
					shipgender	   : shipgender,
					custtype	   : custtype,
					fname		   : fname,
					lname		   : lname,
					shipfname		: shipfname,
					shiplname		: shiplname,
					companyname	   : companyname,
					vatid	        : vatid,
					phoneCntry	   : phoneCntry,
					phoneArea	   : phoneArea,
					phoneNo		   : phoneNo,
					email		   : email,
					invStreet	   : invStreet,
					invAdditional  : invAdditional,
					invZip		   : invZip,
					invCity		   : invCity,
					invCntry	   : invCntry,
					invCountryName	   : invCountryName,
					invRegion	   : invRegion,
					shipStreet	   : shipStreet,
					shipAdditional : shipAdditional,
					shipZip		   : shipZip,
					shipCity	   : shipCity,
					shipCountry	   : shipCountry,
					shipCountryName	   : shipCountryName,
					shipRegion	   : shipRegion,
					sameAdd		   : sameAdd,
					newPasswd	   : newPasswd,
					createacc	   : document.getElementById("hidCreateAccount").value,
					hidAction    : 'createAcc'
				},

				function (response,responsetext) {
					if(url =='create_account.html') {

						if(host==response){
							window.location='my_account.html';
						}else{
							window.location= "http://"+response+"/my_account.html?custom="+getCookie($("#hidPHPSessionName").val());
						}

					}else{
						//location.reload();
						window.location= "checkout_shipping.html?custom="+getCookie($("#hidPHPSessionName").val());
					}
				}
		);  		

}


function addProdToCart(){




	if($("#productOption").attr("selectedIndex")!="0" && $("#prodQty").val() >"0"){
		$('#addToCartBtn').css("display","none");
		$('#addToCartwait').css("display","block");
		
		optionId    = $("#productOption").val();
		prodId      = $("#hidProdId").val();
		prodQty     = $("#prodQty").val();
		hidOptionId = $("#hidOptionId").val();

		$.getJSON(window.location.pathname,{hidAction: "addToCart",productId:prodId,optionId:optionId,prodQty:prodQty,hidOptionId:hidOptionId}, 
			function(data) {
			window.location ="shopping_cart.html";
			
		}
		);
 	}





}



function showCartToolTip(id)
{
	if(document.getElementById("productOption").selectedIndex=="0" ){
		// addToCartToolTip is the css class
		toolTip(alerts['1041'],'addToCartToolTip', 200, 100);
		return false

	}else if(document.getElementById("prodQty").value=="0" || document.getElementById("prodQty").value==""){
		toolTip(alerts['1012'],'addToCartToolTip', 200, 100);
		return false
	}else{
		document.getElementById(id).title="";
	}
}









/*******************************************tooltip.js***************************************/

/*
 

======================================================================================================

 This script was tested with the following systems and browsers:

 - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2
 - Mac OS X:   IE 5, Safari 1

 If you use another browser or system, this script may not work for you - sorry.

------------------------------------------------------------------------------------------------------

 USAGE:

 Use the toolTip-function with mouse-over and mouse-out events (see example below).

 - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent)
   Note: width and opacity are optional. Opacity is not supported by all browsers.

 - To hide a tooltip, use this syntax: toolTip()

------------------------------------------------------------------------------------------------------

 EXAMPLE:

 <a href="#" onMouseOver="toolTip('Just a test', 150)" onMouseOut="toolTip()">some text here</a>

======================================================================================================
*/

var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;

function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
//give these in css class
//this.width = 200;                     // width (pixels)
//this.bgColor = "#FFFFC0";             // background color
//this.textFont = "Comic Sans MS";      // text font family
//this.textFont = "Arial, Helvetica, Sans-serif";      // text font family
//this.textSize = 13;                   // text font size (pixels)
//this.textColor = "#A00000";           // text color
//this.border = "1px dashed #D00000";   // border (CSS spec: size style color, e.g. "1px solid #D00000")
//this.opacity = 80;                    // opacity (0 - 100); not supported by all browsers
  

// don't change
this.text = '';
this.height = 0;
this.obj = null;
this.active = false;
this.cursorDistance = 5;// distance from mouse cursor (pixels)
//----------------------------------------------------------------------------------------------------
// Methods
//----------------------------------------------------------------------------------------------------
  this.create = function() {
    if(!this.obj) this.init();

   /* var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
            (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
            (this.border ? 'border:' + this.border + '; ' : '') +
            (this.textColor ? 'color:' + this.textColor + '; ' : '');

    var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + '><tr>' +
            '<td align=center' + (s ? ' style="' + s + '"' : '') + '>' + this.text +
            '</td></tr></table>';//vinesh*/
    
	/*var t = '<table border=0 cellspacing=0 cellpadding=4 class='+this.cssclass+'><tr>' +
            '<td align=center >' + this.text +
            '</td></tr></table>';*/
	var t = '<div class='+this.cssclass+'>' + this.text + '</div>';
	
    if(DOM || IE) this.obj.innerHTML = t;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
	if(!this.moveWithMouse){return false;}
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(x + this.width + this.cursorDistance > winX + getScrX())
      x -= this.width + this.cursorDistance;
    else x += this.cursorDistance;

    if(y + this.height + this.cursorDistance > winY + getScrY())
      y -= this.height;
    else y += this.cursorDistance;

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.zIndex = 69;
    this.active = true;
    this.obj.style.visibility = 'visible';
  }

  this.hide = function() {
    this.obj.style.zIndex = -1;
    this.active = false;
    this.obj.style.visibility = 'hidden';
  }

  this.setOpacity = function() {
    this.obj.style.opacity = this.opacity / 100;
    this.obj.style.MozOpacity = this.opacity / 100;
    this.obj.style.KhtmlOpacity = this.opacity / 100;
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
  }
}

//----------------------------------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------------------------------
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

function toolTip(text, cssclass, width, opacity) {
  if(text) {
    tooltip = new TOOLTIP();
    tooltip.text = text;
    tooltip.moveWithMouse = (arguments[4]==false)?arguments[4]:true;//if no need to move tooltip with mouse,pass argument 5 as false
	if(cssclass && cssclass!='')
    tooltip.cssclass = cssclass;
    if(width && width!='') tooltip.width = width;
    if(opacity && opacity!='') tooltip.opacity = opacity;
    tooltip.create();
  }
  else if(tooltip) tooltip.hide();
}

//----------------------------------------------------------------------------------------------------
// Build tooltip box
//----------------------------------------------------------------------------------------------------
document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>');

//----------------------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------------------
var mouseX = mouseY = 0;
document.onmousemove = getMouseXY;

//----------------------------------------------------------------------------------------------------




function MakeWrapCost() {


		if(document.getElementById('wrapcheckbox').checked){
			document.getElementById('shipmentcost').innerHTML = document.getElementById('hidShipWrapCost').value;
			//document.getElementById('hidTotalShipCost').value = document.getElementById('hidShipWrapCostwithoutdelim').value;
			GiftWrap = 'on';
		}else{
			document.getElementById('shipmentcost').innerHTML = document.getElementById('hidShipCost').value;
			//document.getElementById('hidTotalShipCost').value = document.getElementById('hidShipCostwithoutdelim').value;
			GiftWrap = 'off';

		}



		$.getJSON(
				'checkout_shipping.html', 
					{
						giftWrap     : GiftWrap,
						hidAction : 'giftwrap'
					},
					function (response,responsetext) {

					}
			); 

}



function checkCoupon() {


	if(!document.getElementById('enteredcouponnum').value){
		document.getElementById('couponerrormessage').style.display = '';
		document.getElementById('couponerrormessage').innerHTML = alerts['1043'];
		return false
	}

			
			
			$.getJSON(
				'checkout_shipping.html', 
					{
						coupon : document.getElementById('enteredcouponnum').value,
						hidAction   : 'checkcoupon'
					},
					function (response,responsetext) {


						if(response=='nocoupon'){

							document.getElementById('couponerrormessage').style.display = '';
							document.getElementById('couponerrormessage').innerHTML = alerts['1061'];
							document.getElementById('couponamount1').innerHTML = document.getElementById('hidNullPrice').value;
							document.getElementById('couponamt').style.display = 'none';
							document.getElementById('validateimg').style.display = 'none';

						}else{

							document.getElementById('couponerrormessage').style.display = 'none';
							document.getElementById('couponamt').style.display = '';
							document.getElementById('validateimg').style.display = '';
							document.getElementById('couponamount1').innerHTML = response['delim'];
							document.getElementById('couponamount2').innerHTML = response['delim'];
							

						}
					}
			); 




}

// payment type indx for credit card
var CreditPayment = '1';
// payment type indx for debit
var DebitPayment = '2';
// payment type indx for pre-paid
var PrePaid = '12';

// payment type indx for pay pal
var PayPal = '14';

// payment type indx for sofort
var Sofort = '17';
var Cheque = '15';
var DirectDeposit = '18';
var COD = '10';

function changePayTypes(paytypeindx, payname)
{
	document.getElementById('hidPaymentType').value =paytypeindx;


 if(paytypeindx == CreditPayment ) {
		document.getElementById('creditcard').style.display = '';
        document.getElementById('debitcard').style.display = 'none';
        document.getElementById('prepaid').style.display = 'none';
        document.getElementById('cheque').style.display = 'none';
        document.getElementById('directdeposit').style.display = 'none';
	}else if(paytypeindx ==DebitPayment ) {
		document.getElementById('creditcard').style.display = 'none';
		document.getElementById('prepaid').style.display = 'none';
		document.getElementById('cheque').style.display = 'none';
		document.getElementById('directdeposit').style.display = 'none';
        document.getElementById('debitcard').style.display = '';
	}else if(paytypeindx ==PrePaid ) {
		document.getElementById('creditcard').style.display = 'none';
        document.getElementById('debitcard').style.display = 'none';
        document.getElementById('directdeposit').style.display = 'none';
        document.getElementById('cheque').style.display = 'none';
        document.getElementById('prepaid').style.display = '';
	}else if(paytypeindx ==Cheque ) {
		document.getElementById('creditcard').style.display = 'none';
        document.getElementById('debitcard').style.display = 'none';
        document.getElementById('directdeposit').style.display = 'none';
        document.getElementById('cheque').style.display = '';
        document.getElementById('prepaid').style.display = 'none';
	}else if(paytypeindx ==DirectDeposit ) {
		document.getElementById('creditcard').style.display = 'none';
        document.getElementById('debitcard').style.display = 'none';
        document.getElementById('directdeposit').style.display = '';
        document.getElementById('cheque').style.display = 'none';
        document.getElementById('prepaid').style.display = 'none';
	}else if(paytypeindx ==COD ) {
		document.getElementById('creditcard').style.display = 'none';
        document.getElementById('debitcard').style.display = 'none';
        document.getElementById('directdeposit').style.display = 'none';
        document.getElementById('cheque').style.display = 'none';
        document.getElementById('prepaid').style.display = 'none';

	}else{
		document.getElementById('creditcard').style.display = 'none';
        document.getElementById('debitcard').style.display = 'none';        
        document.getElementById('prepaid').style.display = 'none';        
        document.getElementById('cheque').style.display = 'none';        
        document.getElementById('directdeposit').style.display = 'none';        
	}




				$.getJSON(
				'checkout_shipping.html', 
					{
						paytype         : paytypeindx,
						payname         : payname,
						hidAction   : 'paymentfee'
					},
					function (response,responsetext) {

						if(response['price']=='false'){

							document.getElementById('paymentfee').innerHTML = document.getElementById('hidNullPrice1').value;


						}else{

							document.getElementById('paymentfee').innerHTML = response['delim'];

							

						}
					}
			); 




	
}




function updateShipPay() {

	if(document.getElementById('couriesservice').value == '-') {
		alert(alerts['1047']);
		return false;
	}

	if(!$('input[name=paymenttypes]:checked').val()){
		alert(alerts['1062']);
		return false;
	}


	var paymentTypeIndx = $('input[name=paymenttypes]:checked').val();

	
	var myRandomNumber = getRandom(1111,9999);

	if ( paymentTypeIndx == CreditPayment ){

		credit_name     = document.forms[0].credit_name.value;
		credit_number   = document.forms[0].credit_number.value;
		var cc_no = parseInt(credit_number)+1111111111+myRandomNumber;
		cc_no += ':'+myRandomNumber;

		credit_expmonth = document.forms[0].credit_expmonth.value;
		credit_expyear  = document.forms[0].credit_expyear.value;
		credit_code     = document.forms[0].credit_code.value;

		bank_name_1  = '';
		bank_code_1  = '';
		bank_account = '';


		// validate the credit card entries
		if (!CreditCardValidation() ){
			return false;
		}
	}
	// if debit payment is selected
	else if (paymentTypeIndx == DebitPayment ){

		bank_name_1  = document.forms[0].bank_name_1.value;
		bank_code_1  = document.forms[0].bank_code_1.value;
		bank_account = document.forms[0].bank_account.value;
		var bankaccno = parseInt(bank_account)+1111111111+myRandomNumber;
		bankaccno += ':'+myRandomNumber;
		credit_name     ='';
		credit_number   ='';
		credit_expmonth ='';
		credit_expyear  ='';
		credit_code     ='';


		// validate the bank details
		if (!BankValidation() ){
			return false;
		}
	}else{


		bank_name_1  = '';
		bank_code_1  = '';
		bank_account = '';

		credit_name     ='';
		credit_number   ='';
		credit_expmonth ='';
		credit_expyear  ='';
		credit_code     ='';

	}




		$.getJSON(
				'checkout_shipping.html', 
					{
							credit_name     : credit_name,
							credit_number   : credit_number,
							cc_noencry  : cc_no,
							credit_expmonth : credit_expmonth,
							credit_expyear  : credit_expyear,
							credit_code     : credit_code,
							bank_name_1  : bank_name_1,
							bank_code_1  : bank_code_1,
							bank_account : bank_account,
							bankaccnoency : bankaccno,
						    hidAction   : 'savepay'
					},
					function (response,responsetext) {

						window.location ="checkout_confirmation.html"

					}
			); 




}



//get a random number
function getRandom(min,max)
{
   return (Math.round(Math.random()*(max-min)))+min;
}


function CreditCardValidation()
{
    // user name is not entered
    if( document.forms[0].credit_name.value.match(/^ *$/) )
    {
		 document.getElementById('ccerrormsg1').style.display = '';   
		 document.getElementById('ccerrormsg2').style.display = 'none';   
		 document.getElementById('ccerrormsg3').style.display = 'none';   
		 document.getElementById('ccerrormessage1').innerHTML = alerts['1014'];
		 document.forms[0].credit_name.focus();

        return false;
    }
    // card number is not entered
    else if( document.forms[0].credit_number.value.match(/^ *$/) )
    {
		 document.getElementById('ccerrormsg2').style.display = '';   
		 document.getElementById('ccerrormsg1').style.display = 'none';   
		 document.getElementById('ccerrormsg3').style.display = 'none';   
		 document.getElementById('ccerrormessage2').innerHTML = alerts['1048'];
		 document.forms[0].credit_number.focus();

        return false;
    }
    // not a numeric card number
    else if( isNaN( document.forms[0].credit_number.value ) )
    {
		document.getElementById('ccerrormsg2').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg3').style.display = 'none';   
		document.getElementById('ccerrormessage2').innerHTML = alerts['1049'];
        document.forms[0].credit_number.focus();
        return false;
    }
    // length is more than 19
    else if( document.forms[0].credit_number.value.length > 19 )
    {
		document.getElementById('ccerrormsg2').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg3').style.display = 'none';   
		document.getElementById('ccerrormessage2').innerHTML = alerts['1050'];
        document.forms[0].credit_number.focus();
        return false;
    }
    // not a valid month
    else if( document.forms[0].credit_expmonth.value == '0' )
    {
		document.getElementById('ccerrormsg3').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg2').style.display = 'none';   
		document.getElementById('ccerrormessage3').innerHTML = alerts['1051'];
        document.forms[0].credit_expmonth.focus();
        return false;
    }
    // expiry year is not entered
    else if( document.forms[0].credit_expyear.value.match(/^ *$/) )
    {
		document.getElementById('ccerrormsg3').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg2').style.display = 'none';   
		document.getElementById('ccerrormessage3').innerHTML = alerts['1052'];
        document.forms[0].credit_expyear.focus();
        return false;
    }
    // not a numeric expiry year
    else if( isNaN( document.forms[0].credit_expyear.value ) )
    {
		document.getElementById('ccerrormsg3').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg2').style.display = 'none';   
		document.getElementById('ccerrormessage3').innerHTML = alerts['1049'];
        document.forms[0].credit_expyear.focus();
        return false;
    }
    // year not in format
    else if( (document.forms[0].credit_expyear.value.length > 4) || (document.forms[0].credit_expyear.value.length < 2) ||  (document.forms[0].credit_expyear.value.length == 3))
    {
		document.getElementById('ccerrormsg3').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg2').style.display = 'none';   
		document.getElementById('ccerrormessage3').innerHTML = alerts['1053'];
        document.forms[0].credit_expyear.focus();
        return false;
    }
    else
    {
        //triming the spaces in credit card number          
        var credit_card_no =  ( document.forms[0].credit_number.value );
        // var credit_card_no = document.forms[0].credit_number.value.replace(/^ */g, '').replace(/ *$/g, '');

        //credit card validation            
        var check = CCValidation( credit_card_no );
        
        // valid cc no
        if( check )
        {	

			if(document.forms[0].credit_expyear.value.length == 2){
				credit_expyear= '20'+document.forms[0].credit_expyear.value;
			}else {

				credit_expyear= document.forms[0].credit_expyear.value;
			}

            //expiry date for credit card validation
            var datchk = ValidateExpiry( document.forms[0].credit_expmonth.value, credit_expyear );
            
            // valid expiry date
            if ( datchk )
            {
			    document.getElementById('ccerrormsg1').style.display = 'none';   
			    document.getElementById('ccerrormsg2').style.display = 'none';   
				document.getElementById('ccerrormsg3').style.display = 'none';   
                
				return true;
            }
            // invalid expiry date
            else
            {
				document.getElementById('ccerrormsg3').style.display = '';   
			    document.getElementById('ccerrormsg1').style.display = 'none';   
			    document.getElementById('ccerrormsg2').style.display = 'none';   
				document.getElementById('ccerrormessage3').innerHTML = alerts['1054'];
				document.forms[0].credit_expyear.focus();
                return false;
            }
        }
        // not a valid credit card
        else
        {
            return false;
        }
    }
}


// credit card validtion...
// checks for the length of the credit card 
function CCValidation( credit_number )
{
    var NumberLeft = credit_number.substr( 0, 4 );
    var NumberLength = credit_number.length;
    var ShouldLength
    var Missing;
    var CardName = '';
	/*   if ( (NumberLeft >= 3000) && (NumberLeft <= 3059) ) 
    {
        CardName = 'Diners Club';
        ShouldLength = 14;
    } 
    else if ( (NumberLeft >= 3600) && (NumberLeft <= 3699) ) 
    {
        CardName = 'Diners Club';
        ShouldLength = 14;
    } 
    else if ( (NumberLeft >= 3800) && (NumberLeft <= 3889) ) 
    {
        CardName = 'Diners Club';
        ShouldLength = 14;
    } 
    else if ( (NumberLeft >= 3400) && (NumberLeft <= 3499) ) 
    {
        CardName = 'American Express';
        ShouldLength = 15;
    } 
    else if ( (NumberLeft >= 3700) && (NumberLeft <= 3799) ) 
    {
        CardName = 'American Express';
        ShouldLength = 15;
    } 
    else if ( (NumberLeft >= 3528) && (NumberLeft <= 3589) ) 
    {
        CardName = 'JCB';
        ShouldLength = 16;
    } 
    else if ( (NumberLeft >= 3890) && (NumberLeft <= 3899) ) 
    {
        CardName = 'Carte Blache';
        ShouldLength = 14;
    } 
    else if ( (NumberLeft >= 4000) && (NumberLeft <= 4999) ) 
    {
        CardName = 'Visa';
        if (NumberLength > 14) 
        {
            ShouldLength = 16;
        } 
        else if (NumberLength < 14) 
        {
            ShouldLength = 13;
        }
    } 
    else if ( (NumberLeft >= 5100) && (NumberLeft <= 5599) ) 
    {
        CardName = 'MasterCard';
        ShouldLength = 16;
    } 
    else if (NumberLeft == 5610) 
    {
        CardName = 'Australian BankCard';
        ShouldLength = 16;
    } 
    else if (NumberLeft == 6011) 
    {
        CardName = 'Discover/Novus';
        ShouldLength = 16;
    } 
    else
    {
        // CardName = 'Test Value';
        // ShouldLength = 16;
    }
    */

	if ( (NumberLeft >= 4000) && (NumberLeft <= 4999) ) 
    {
        CardName = 'Visa';
        if (NumberLength > 14) 
        {
            ShouldLength = 16;
        } 
        else if (NumberLength < 14) 
        {
            ShouldLength = 13;
        }
    } 
    else if ( (NumberLeft >= 5100) && (NumberLeft <= 5599) ) 
    {
        CardName = 'MasterCard';
        ShouldLength = 16;
    } 
     else
    {
        // CardName = 'Test Value';
        // ShouldLength = 16;
    }

    // invalid card no... not the proper length 
    if (NumberLength != ShouldLength) 
    {
        // if card name found.. show error for the card name
        if ( CardName != '' )
        {
			document.getElementById('ccerrormsg2').style.display = '';   
			document.getElementById('ccerrormsg1').style.display = 'none';   
			document.getElementById('ccerrormsg3').style.display = 'none';   
			document.getElementById('ccerrormessage2').innerHTML = alerts['1048'];
			document.forms[0].credit_number.focus();
        }
        // cc not supported
        else
        {
			document.getElementById('ccerrormsg2').style.display = '';   
			document.getElementById('ccerrormsg1').style.display = 'none';   
			document.getElementById('ccerrormsg3').style.display = 'none';   
			document.getElementById('ccerrormessage2').innerHTML = alerts['1056'];
			document.forms[0].credit_number.focus();
		}
        return false;
    } 

    // mod 10 algorithm
    if( Mod10Solution( credit_number ) ) 
    {
		// store the cc name
		//document.forms[0].hidvalccname.value = CardName;
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg2').style.display = 'none';   
		document.getElementById('ccerrormsg3').style.display = 'none';   

        return true;
    } 
    // failed
    else 
    {
		document.getElementById('ccerrormsg2').style.display = '';   
		document.getElementById('ccerrormsg1').style.display = 'none';   
		document.getElementById('ccerrormsg3').style.display = 'none';   
		document.getElementById('ccerrormessage2').innerHTML = alerts['1048'];
		document.forms[0].credit_number.focus();

        return false;
    }
}

function Mod10Solution( Number ) 
{
    var NumberLength = Number.length;
    var Checksum = 0;
    var Location;
    var Digit;

    // Add even digits in even length strings or odd digits in odd length strings.
    for (Location = 1-(NumberLength%2); Location<NumberLength; Location+=2) 
    {
        Checksum += parseInt(Number.substr(Location, 1));
    }
    
    // Analyze odd digits in even length strings or even digits in odd length strings.
    for (Location = (NumberLength%2); Location<NumberLength; Location+=2) 
    {
        Digit = Number.substr(Location, 1) * 2;
        if (Digit < 10) 
        {
            Checksum += parseInt(Digit);
        } 
        else 
        {
            Checksum += parseInt(Digit) - 9;
        }
    }

    // Is the checksum divisible by ten?
    return (Checksum % 10 == 0);
}


// validate the expiry date for the card
function ValidateExpiry( month, year )
{ 
    var addyear;
    var rt_val;

    addyear = parseInt( year );
    var mydate = new Date();
    if( mydate.getFullYear() > addyear ) 
    { 
            rt_val = 0;
        
    }else if( mydate.getFullYear() == addyear )   {
        if( mydate.getMonth()+1 <= month ) 
        {
            rt_val = 1;
        } 
        else {
			
            rt_val = 0;
        }
    } else if( mydate.getFullYear() < addyear )  {
		
        rt_val=1;
    } 
    else 
    {
        rt_val = 0;
    }
    return rt_val;
}



// if debit payment is selected
// check whether all valid bank details are entered
function BankValidation()
{
	// bank name not entered
	if( document.forms[0].bank_name_1.value.match(/^ *$/) )
    {
		document.getElementById('debiterrormsg1').style.display = '';   
		document.getElementById('debiterrormsg2').style.display = 'none';   
		document.getElementById('debiterrormsg3').style.display = 'none';   
		document.getElementById('debiterrormessage1').innerHTML = alerts['1058'];
        document.forms[0].bank_name_1.focus();
        return false;
    }
	// bank code not entered
    else if( document.forms[0].bank_code_1.value.match(/^ *$/) )
    {
		document.getElementById('debiterrormsg2').style.display = '';   
		document.getElementById('debiterrormsg1').style.display = 'none';   
		document.getElementById('debiterrormsg3').style.display = 'none';   
		document.getElementById('debiterrormessage2').innerHTML = alerts['1059'];
        document.forms[0].bank_code_1.focus();
        return false;
    }
	// bank accountno not entered
    else if( document.forms[0].bank_account.value.match(/^ *$/) )
    {
		document.getElementById('debiterrormsg3').style.display = '';   
		document.getElementById('debiterrormsg1').style.display = 'none';   
		document.getElementById('debiterrormsg2').style.display = 'none';   
		document.getElementById('debiterrormessage3').innerHTML = alerts['1060'];
        document.forms[0].bank_account.focus();
        return false;
   // data entered properly
	}else{

		document.getElementById('debiterrormsg1').style.display = 'none';   
		document.getElementById('debiterrormsg2').style.display = 'none';   
		document.getElementById('debiterrormsg3').style.display = 'none';   
		 return true;
	}
	
    
}

function loadfindus(val){

	if(val==2 || val==3 || val==4){

		$.getJSON(
				'checkout_confirmation.html', 
					{
						loadus  : val,
						hidAction : 'loadfindus'
					},
					function (response,responsetext) {

						document.getElementById('findusother').style.display = 'none';   
						document.getElementById('findusother_tr').style.display = 'none';   
						document.getElementById('findusother1').style.display = '';   
						document.getElementById('findusother_tr1').style.display = '';   
						document.getElementById('displayOptions').innerHTML = response;
					}
			); 
	}else if(val==5 || val==6 ){

		document.getElementById('findusother').style.display = '';   
		document.getElementById('findusother_tr').style.display = '';   
		document.getElementById('findusother1').style.display = 'none';   
		document.getElementById('findusother_tr1').style.display = 'none';   
	}else{
		document.getElementById('findusother').style.display = 'none';   
		document.getElementById('findusother_tr').style.display = 'none';   
		document.getElementById('findusother1').style.display = 'none';   
		document.getElementById('findusother_tr1').style.display = 'none';   
	}


}


function forOther(value1){
	if (value1=='9'){
		document.getElementById('findusother').style.display = '';   
		document.getElementById('findusother_tr').style.display = '';   
	}
	else{
		document.getElementById('findusother').style.display = 'none';   
		document.getElementById('findusother_tr').style.display = 'none';   
	}

}






function confirmOrder(paymentTypeIndx){


	if(!document.getElementById('checkterms').checked){
		alert(alerts['1063']);
		return false
	}
	
	
	
	subscribe ='n';
	$('#subscribenews input[type=checkbox]:checked').each(function(){

		subscribe ='y';
	})


	if(subscribe =='y' ){
		orderNewsSubsribe(paymentTypeIndx);
	}else{
		placeOrder(paymentTypeIndx);
	}


	$('#confirmorderbutton').css("display","none");
	$('#confirmorderwait').css("display","block");
	
}







function placeOrder(paymentTypeIndx){

	
	prds ='';
	$('#prod_service input[type=checkbox]:checked').each(function(){

		s=$(this).val();

		prds += s+',';
	})
	
	subscribe ='n';
	$('#subscribenews input[type=checkbox]:checked').each(function(){

		subscribe ='y';
	})



	//dob=	$('#custbday').val()
	day =   $("#dob_day").val();
	month = $("#dob_month").val();
	//yyyy-mm-dd
	dob='0000-'+month+'-'+day;
		$.getJSON(
				'checkout_confirmation.html', 
					{
						serviceprods  : prds,
						subscribenews : subscribe,
						findus : document.getElementById('findus').value,
						findusfrom : document.getElementById('displayElem').value,
						findusothermsg : document.getElementById('findusothermsg').value,
						custbday : dob,
						customercomment :  $("#customercomment_1").val(),
						hidAction : 'createCSV'
					},
					function (response,responsetext) {


						switch(paymentTypeIndx){
							case 1: //Credit Card
								//document.forms[0].action = "https://ipayment.de/merchant/33745115/processor.php";
								document.forms[0].action = "checkout_confirmation.html?hidAction=confirm&success=true";

								break;
							case 2: //Debit
								
								//document.forms[0].action = "https://ipayment.de/merchant/33745115/processor.php";
								document.forms[0].action = "checkout_confirmation.html?hidAction=confirm&success=true";
							break;
						
							case 10://Cash on Delivery
							case 12://Pre-Paid
							case 15://Cheque
							case 18://Direct Deposit
							case 20://Purchase order 
								document.forms[0].action = "checkout_confirmation.html?hidAction=confirm&success=true";
								break;
							case 13://moneybookers

								document.forms[0].action = "https://www.moneybookers.com/app/payment.pl";
								break;
						
							case 14://PayPal


								document.forms[0].action = "https://www.paypal.com/cgi-bin/webscr";
								document.forms[0].method = "GET";
								break;
							
							case 17://Sofortüberweisung
										document.forms[0].action = "https://www.directebanking.com/payment/start";

								break;
							case 19://iclear 
								document.forms[0].action = "checkout_confirmation.html?hidAction=iclearSendOrder";
								break;

							default:
								break;
						}
						document.forms[0].submit();



					}
			); 



		}










function openCountryLayer(){
cnty_langlayer = layermodal.open('CountryLangLayer', 'div', 'countrylanguagelayer', document.getElementById('hidcountrylanguage').value, 'width=510px,height=260px,center=1,resize=0,scrolling=0');


}

function CloseCountryLayer(){

	layermodal.close(cnty_langlayer);


}

function setLocation(host,page){


if($('#retain_selection').is(':checked')){
			retain='true';
}else{
	retain='false';

}


var counties =0;
 for(var i = document.getElementById('lbcountrylist').options.length-1; i >=0  ;i--)
    {
		if(document.getElementById('lbcountrylist').options[i].selected){
			counties += parseInt(1);
			var domain =document.getElementById('lbcountrylist').options[i].value;
			var selcountry =document.getElementById('lbcountrylist').options[i].text;
			// text

		}

    }

var languages =0;
 for(var i = document.getElementById('lblanguagelist').options.length-1; i >=0  ;i--)
    {
		if(document.getElementById('lblanguagelist').options[i].selected){
			languages += parseInt(1);

			var lang =document.getElementById('lblanguagelist').options[i].value;
		}

    }





	cntyid   = $('#lbcountrylist :selected').attr('countryid');

	if(counties=='0' || counties>1){

		alert(alerts['1064']);
		return false;

	}

// should not be logged in and the chosen country should not be the country slected on naviagtion
	if(document.getElementById('hidLoggedValue').value=='1' && cntyid!=document.getElementById('hidSelectedCountryID').value) {

			msg = alerts['1080'];

			from  = document.getElementById('hidSelectedCountryName').value;
			to  = selcountry;
			to = to.replace(/^\s\s*/, '').replace(/\s\s*$/, '');

			msg = msg.replace('FROM_COUNTRY', from);

			msg = msg.replace(/TO_COUNTRY/g, to);

			alert(msg);
			return false;
	}

	if(languages=='0' || languages>1){

		alert(alerts['1065']);
		return false;

	}



if(page=='blog'){
	
	if(host == domain) {
		window.parent.location= "http://"+domain;
	}else{

			$.getJSON(
				'shopping_cart.html', 
				{
					countryval  : cntyid,
					langval  : lang,
					cntdomain  : domain,
					retainselection  : retain,
					hidValPage  : 'home',
					hidAction : 'savecountry'
				},
				function (response,responsetext) {

					window.parent.location= "http://"+domain+"/"+response+"?lang="+lang+"&cnty="+cntyid+"&custom="+getCookie($("#hidPHPSessionName").val());
				}
			); 
	}

}else{

	if(host == domain) {
		document.getElementById("hidValCountryAction").value='changecountry';
		document.getElementById("hidValCountryId").value=cntyid;
		document.getElementById("hidLangIndex").value=lang;
		document.getElementById("frmVivalite").submit();
	}else{


			$.getJSON(
				'shopping_cart.html', 
				{
					countryval  : cntyid,
					langval  : lang,
					cntdomain  : domain,
					retainselection  : retain,
					hidValPage  : 'home',
					hidAction : 'savecountry'
				},
				function (response,responsetext) {

					window.location= "http://"+domain+"/"+response+"?lang="+lang+"&cnty="+cntyid+"&custom="+getCookie($("#hidPHPSessionName").val());

				}
			); 






	}
}


}



function LogOut(){


	$.getJSON(
				'enter.html', 
					{
						hidAction   : 'logout'
					},
					function (response,responsetext) {

						window.location ='http://'+$("#hidSessionHost").val();
						
					}
			); 



}


function prodSortOrder(val){

	document.getElementById("hidSortOrder").value=val;
	document.getElementById("frmVivalite").submit();

}


/*from the country selection page*/
/*to show the countries when mouse over on a region*/
showCountries = function(id1,id2)
{

	document.getElementById('entersiteheader_middletext').style.display='none';

	document.getElementById('countrylist1').style.display='none';
	document.getElementById('countrylist2').style.display='none';
	document.getElementById('countrylist3').style.display='none';
	document.getElementById('countrylist4').style.display='none';

	document.getElementById('connection1').style.visibility='hidden';
	document.getElementById('connection2').style.visibility='hidden';
	document.getElementById('connection3').style.visibility='hidden';
	document.getElementById('connection4').style.visibility='hidden';

	document.getElementById(id1).style.display='block';
	document.getElementById(id2).style.visibility='visible';
}

/*to hide the countries when mouse out on a region*/
hideCountries = function(id1,id2)
{
	document.getElementById('entersiteheader_middletext').style.display='block';
	document.getElementById(id1).style.display='none';
	document.getElementById(id2).style.visibility='hidden';
}


userLogin = function(e)
{
	if(e.type=='keypress' && (e.keyCode != 13 && e.keyCode != 9)){//if not enter key or tab key
		return false;
	}else if(document.getElementById("user_login").value.match(/^ *$/)){
		alert(alerts['1001']);
		document.getElementById("user_login").focus();
		return false;
	}else if(!(validateEmail(document.getElementById("user_login").value))){
		alert(alerts['1002']);
		document.getElementById("user_login").focus();
		return false;
	}else if(document.getElementById("user_password").value.match(/^ *$/)){
		alert(alerts['1028']);
		document.getElementById("user_password").focus();
		return false;
	}else{
		//check username and password are correct
		checkLogin('home');
	}
}



function prodQtyDiscountLayer(prodid,optid,name,title,indx,minqty){

	nametitle =name+', '+title;

	img ='<img src ="tl_files/img/5220.jpg"/>';
	$.getJSON(
				'shopping_cart.html', 
					{
						prodid   : prodid,
						optid   : optid,
						hidAction   : 'qtydiscount'
					},
					function (response,responsetext) {
						tr  ='<table width="100%" style="font-size:12px">';
						tr += "<tr height='5px'></tr>";
						for(var i = 0; i < response.length; i++){
							tr += "<tr>";
							tr += "<td  width='25%' >"+response[i].from+"</td>";
							tr += "<td  width='25%' align='center'>"+response[i].price+"</td>";
							tr += "<td  width='20%' align='center'>"+response[i].percent+"</td>";
							tr += "<td  width='30%' align='right' style='color:red'>- "+response[i].discount+"</td>";
							tr += "</tr>";
							if(i != (response.length)-1) {
								tr += "<tr >";
								tr += "		<td colspan='4' class='cartline' ></td>";
								tr += "	</tr>";
							}
							tr += "<tr height='5px'></tr>";


						}
						tr +='</table>';



						prodqtylayer = layermodal.open('EmailBox', 'div', 'prodQtyDiscountLayer', nametitle, 'width=455px,height=350px,center=1,resize=0,scrolling=0');
						
						document.getElementById('prodqtydiv').innerHTML = tr;
						document.getElementById('hidCartIndx').value       = indx;
						document.getElementById('hidCartProdName').value   = name;
						document.getElementById('hidCartProdMinQty').value = minqty;
						document.getElementById('hidCartProdId').value = prodid;
						document.getElementById('hidCartOptId').value = optid;


						//document.getElementById("test111").innerHTML = img+' '+nametitle;

				}
			); 




}

function setProdQty(){



	qty      = document.getElementById('productqtydiscountval').value ;

	if(isNaN(qty) || qty.match(/\.+/) || qty == '' || qty < 1){
		alert(alerts['1012']);
		 document.getElementById('productqtydiscountval').focus();
		return false;
	}
	indx     = document.getElementById('hidCartIndx').value;
	prodname = document.getElementById('hidCartProdName').value;
	minqty   = document.getElementById('hidCartProdMinQty').value;
	document.getElementById('cartprodquantity_'+indx).value =qty;

	updateCartQuantity(indx,qty,prodname,minqty)

	layermodal.close(prodqtylayer);

}

function setCartqty(){
	qty     = document.getElementById('productqtydiscountval').value;
	if(isNaN(qty) || qty.match(/\.+/) || qty == '' || qty < 1){
		alert(alerts['1012']);
		 document.getElementById('productqtydiscountval').focus();
		return false;
	}
	prodid   = document.getElementById('hidCartProdId').value ;
	optid     = document.getElementById('hidCartOptId').value;
	$.getJSON(
				'shopping_cart.html', 
					{
						prodid   : prodid,
						optid   : optid,
						cartqty   : qty,
						hidAction   : 'setcartqty'
					},
					function (response,responsetext) {

						document.getElementById('qtydiscountprice').innerHTML = response;

					}
			); 

}







function calculateEnergy(percent)
{
	current_wattage = document.getElementById("current_wattage").value;
	number_hours_day = document.getElementById("number_hours_day").value;
	number_bulbs = document.getElementById("number_bulbs").value;
	energy_cost = document.getElementById("energy_cost").value;

	energy_cost = energy_cost.replace(",", '.');

	if(number_hours_day>24){
		alert(alerts['1077']);
		document.getElementById("number_hours_day").value='4';
		//return;
		number_hours_day = document.getElementById("number_hours_day").value;

	}
	anualCost = roundNumber(((current_wattage*number_hours_day*number_bulbs*energy_cost*365)/1000),2);
	/*  100000 = 1000 kw * 100 cent*/
	new_cost = anualCost/5;

	document.getElementById("old_cost").innerHTML = anualCost;
	document.getElementById("equivalent_bulb").innerHTML = (current_wattage*percent/100);
	document.getElementById("new_cost").innerHTML = roundNumber(new_cost,2);
	document.getElementById("saving").innerHTML = roundNumber(anualCost-new_cost,2);
	document.getElementById("cur_wat").innerHTML = current_wattage+'W';

}

function roundNumber(rnum, rlength) { 
	return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}



function changeDeliveryAddress(val){


			$.getJSON(
			window.location.pathname,
				{
					addressindx		  : val,
					hidAction  : 'changeaddress'
				},

				function (response,responsetext) {

					$("#delfname").val(response['fname']);
					$("#dellname").val(response['lname']);
					$("#shipStreet").val(response['street']);
					$("#shipAdditional").val(response['additional']);
					$("#shipCity").val(response['city']);
					$("#shipZip").val(response['zip']);
					$("#shipRegion").val(response['region']);
					$("#shipCountry").val(response['country']);
					$("#hidValShipAddIndx").val(val);
					$("#shipGender_"+response['gender']).attr('checked', true);

					if(!response['gender']){
						$('span input[name=shipGender]').attr('checked',false)
					}



				}
		);  

}
function changeInvoiceAddress(val){


			$.getJSON(
			window.location.pathname,
				{
					addressindx		  : val,
					hidAction  : 'changeaddress'
				},

				function (response,responsetext) {

					$("#fname").val(response['fname']);
					$("#lname").val(response['lname']);
					$("#invStreet").val(response['street']);
					$("#invAdditional").val(response['additional']);
					$("#invCity").val(response['city']);
					$("#invZip").val(response['zip']);
					$("#invRegion").val(response['region']);
					$("#invCntry").val(response['country']);
					$("#hidValInvAddIndx").val(val);
					$("#invGender_"+response['gender']).attr('checked', true);
					if(!response['gender']){
						$('span input[name=invGender]').attr('checked',false)
					}



				}
		);  

}



function deleteDelAddress(){

	del_addr= $("#lbdeladdress").val();
	sel_inv= $("#lbinvaddress").val();


	if(del_addr=='new'){
		alert(alerts['1081']);
		return false;
	}

	if(del_addr==sel_inv && document.getElementById('addresscheckbox').checked==false){

		//alert('You cannot delete a address which is selected as invoice address');
		alert(alerts['1082']);
		return false;
	}


	flag= window.confirm(alerts['1045']);

	if(flag){

		$.getJSON(
				window.location.pathname,
					{
						del_addr		  : del_addr,
						inv_addr		  : document.getElementById("hidValInvAddIndx").value,
						hidAction  : 'delete_deladd'
					},

					function (response,responsetext) {

						if(response['cnt']=='1'){
							document.getElementById("addresscheckbox").checked='true';
							makeAddressDisplay();
							document.getElementById("deletedeladdressdiv").style.visibility='hidden';
							document.getElementById("deleteinvaddressdiv").style.visibility='hidden';

						}
						$("#lbdeladdress option[value="+del_addr+"]").remove();
						$("#lbinvaddress option[value="+del_addr+"]").remove();

						$("#lbdeladdress").val(response['addrindx'])
						changeDeliveryAddress(response['addrindx'])
					}
			);  
	}


}


function deleteInvAddress(){

	sel_del= $("#lbdeladdress").val();
	inv_addr= $("#lbinvaddress").val();

	if(inv_addr=='new'){
		alert(alerts['1081']);
		return false;
	}

	if(sel_del==inv_addr){

		alert(alerts['1083']);
		return false;
	}


	flag= window.confirm(alerts['1045']);

	if(flag){


		$.getJSON(
				window.location.pathname,
					{
						inv_addr		  : inv_addr,
						del_addr		  : document.getElementById("hidValShipAddIndx").value,
						hidAction  : 'delete_invadd'
					},

					function (response,responsetext) {
						if(response['cnt']=='1'){
							document.getElementById("addresscheckbox").checked='true';
							makeAddressDisplay();
							document.getElementById("deletedeladdressdiv").style.visibility='hidden';
							document.getElementById("deleteinvaddressdiv").style.visibility='hidden';
							$("#lbdeladdress").val(response['addrindx'])
							changeDeliveryAddress(response['addrindx'])
						}
						$("#lbinvaddress option[value="+inv_addr+"]").remove();
						$("#lbdeladdress option[value="+inv_addr+"]").remove();
						$("#lbinvaddress").val(response['addrindx'])
						changeInvoiceAddress(response['addrindx'])
					}
			);  
	}





}

function sendCartIdMail(cartid) {

	if(!(validateEmail($("#cartemail_to").val())))
	{
		alert(alerts['1002']);
		$("#cartemail_to").focus();
		return;
	}
	if(!(validateEmail($("#cartemail_from").val())))
	{
		alert(alerts['1002']);
		$("#cartemail_from").focus();
		return;
	}
	

	$.getJSON(
				'shopping_cart.html', 
					{
						cartemail_to   : $("#cartemail_to").val(),
						cartemail_from : $("#cartemail_from").val(),
						cartemail_note : $("#cartemail_note").val(),
						hidAction  : 'sendcartid'
					},
					function (response,responsetext) {
						if(response=='mailsendFailed'){
							alert(alerts['1086']);
						}

					}
		); 

	closeEmailLayer();



}





function openCartEmailLayer(){
	cartemail = layermodal.open('EmailBox', 'div', 'cartEmailLayer', alerts['1087'], 'width=425px,height=205px,center=1,resize=0,scrolling=0');

}

function closeEmailLayer(){

	layermodal.close(cartemail);

}


function sendPromotion(label_email,label_name){
	
	var nomail=true;
	for(i=1;i<=5;i++){
		if($("#gift_custemail_"+i).val()!=label_email){
			nomail=false;
		}
	}


	for(i=1;i<=5;i++){
		if($("#gift_custemail_"+i).val()!=label_email && $("#gift_custname_"+i).val()==label_name){
			alert(alerts['1088']);
			$("#gift_custname_"+i).focus();
			return false;
		}
	}
	for(i=1;i<=5;i++){
		if($("#gift_custname_"+i).val()!=label_name && !(validateEmail($("#gift_custemail_"+i).val()))){
			alert(alerts['1002']);
			$("#gift_custemail_"+i).focus();
			return false;
		}
	}


	for(i=1;i<=5;i++){
		if($("#gift_custname_"+i).val()!=label_name && (validateEmail($("#gift_custemail_"+i).val())) && $("#gift_coupon_"+i).val()=='new' ){
			alert(alerts['1089']);
			$("#gift_coupon_"+i).focus();
			return false;
		}
	}

	if(nomail){
		alert(alerts['1002']);
		return false;
	}

	var details='';
	for(i=1;i<=5;i++){
		if($("#gift_custname_"+i).val()!=label_name && (validateEmail($("#gift_custemail_"+i).val())) && $("#gift_coupon_"+i).val()!='new' ){


			gender    = $("#gift_gender_"+i).val();
			name      = $("#gift_custname_"+i).val();
			email     = $("#gift_custemail_"+i).val();
			promoval  = $("#gift_coupon_"+i).val();
			promotext = $("#gift_coupon_"+i+" :selected").attr('promotext');

			details += gender+'$#$'+name+'$#$'+email+'$#$'+promoval+'$#$'+promotext+'$*$';
		}
	}


	$('#cartpromosent').css("display","none");
	$('#cartpromowait').css("display","block");

	$.getJSON(
				'checkout_success.html', 
					{
						promodetails   : details,
						custname   : $("#hidCustLName").val(),
						custtitle  : $("#hidCustGender").val(),
						custemail  : $("#hidCustEmail").val(),
						hidAction  : 'sendpromo'
					},
					function (response,responsetext) {
						if(response=='mailsendSuccess'){

							for(i=1;i<=5;i++){
								$("#gift_custemail_"+i).val(label_email)
								$("#gift_custname_"+i).val(label_name)
							    $("#gift_coupon_"+i).val('new');
							}
							alert(alerts['1090']);
							$('#cartpromosent').css("display","block");
							$('#cartpromowait').css("display","none");

						}else{
							alert(alerts['1086']);
						}

					}
		); 	
}


function orderSummaryLayer(){

	summarylayer = layermodal.open('EmailBox', 'div', 'ordersummarylayer', alerts['1091'], 'width=650px,height=250px,center=1,resize=0,scrolling=1');
}


function orderNewsSubsribe(paymentTypeIndx){

		interests ='';
		if($('#mce-group-2-0').is(':checked')){
			interests +=$('#mce-group-2-0').val();
		}
		if($('#mce-group-2-1').is(':checked')){
			interests += ','+$('#mce-group-2-1').val();
		}
		if($('#mce-group-2-2').is(':checked')){
			interests +=','+$('#mce-group-2-2').val();
		}


		if(!interests){
			interests =$('#mce-group-2-0').val()+','+$('#mce-group-2-1').val()+','+$('#mce-group-2-2').val();
		}

		 $.getJSON(
		'ajax.php?action=fmd&id=54',
			{
				newsemail       : $('#mce-EMAIL').val(),
				newsInterests   : interests,
				newsLetterFname   : $('#mce-FNAME').val(),
				newsLetterLname   : $('#mce-LNAME').val(),
				newsletterGender   : $('#genderindx').val(),
				newsGender        : $('#mce-TITLE').val(),
				newsCountry     : $('#mce-CNTY').val(),
				newsLanguage    : $('#mce-LANG').val(),
				newsZip   : $('#mce-ZIP').val(),
				newsCity  :  $('#mce-CITY').val(),
				newsletterVal : $('#mce-NEWSLETTER').val(),
				newsCustVal :  $('#mce-CUST').val(),
				newsCompany :  $('#mce-COMPANY').val(),
				hidAction       : 'subscribeNewsOrder'
			},
			function (response,responsetext) {
						placeOrder(paymentTypeIndx)
			}
		);

	}



function updateCartPage()	{		
	
	
	$.getJSON(
				'shopping_cart.html', 
				{
					hidAction : 'updatecartpage'
				},
				function (response,responsetext) {

					location.reload();

				}
			); 

}

function hideCommentTextArea(){
	$("#customercomment_1").toggle(100);
}

validateEmail = function(email){


	if(!(/^\w+([\.!#$%&'*+-/=?^_`{|}~-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/.test(email))){
		return false;
	}
		return true;

}
