	var	domII=document.getElementById
	var	ieII=document.all
	
	var crossobj;
	var refobj;
	var largeViewCounter=0;
	var master_asset_number=0;
	var image_number=0;
	var creditcard=-11;
	var state = "";
	var country = "";
	var xmlHttp=GetXmlHttpObject();
	var usa_shipping_time;
	var international_shipping_time;
	var usa_shipping_options;
	var international_shipping_options;
	var LOWEST_SHIPPING_SERVICE;
	var LOWEST_SHIPPING_PRICE;
	var tmp="";
	var uspsfreeamount=0;
	var ship_rates = new Array();
	
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	
	var shoppingAmount;
	var shippByUSPS;
	var fedexPON;
	var fedexSON;
	var ownFedexPON;
	var ownFedexSON;
	
	var max_char_limit=0;
	var max_char_obj;
	
	var lighboxInvokedFrom = "";
	var currentLighbox = "";
	var tmpVar = "";
	var maxhightForP2 = 0;
	var hightForP2 = 0;
	var loggedIn = 0;
	var birth_day_history_search = 0;
	var is_guest = 0;
	
	/* This fusntion runs when any page loads */
	startUp();
	
	function startUp()
	{
	  document.observe("dom:loaded", function()
		{
		  getBrowserInfo();
		  //if(browser == "Internet Explorer 6.0" || browser == "Internet Explorer 7.0" || browser == "Internet Explorer 8.0")
		  //{
			//keepsessionalive();
		  //}
		  //var t = document.getElementsByClassName('myclassname');
		});
		}
	
	function keepsessionalive()
	{
	  
	  setInterval(function(){var args="";var f="keepalivesession";args+= Math.random() + "0|";args+= Math.random() + "0|";args+= Math.random() + "2|";args+= Math.random() + "251|"; args=Base64.encode(args);f=Base64.encode(f);var str=f+"__"+args;url=SITE_URL+'user/wrapperF/'+str;custome_requester(url)}, 5000);
	}
	
	function custome_requester(urlGC)
	{
		new Ajax.Request(urlGC, {
		  method: 'get',
		  onSuccess: function(transport) {
			//alert("Logged out successfullly");
		  }
		});
	}
	
    function changeAmount(me,servicename)
    {
	  var tr = eval(me);
	  if(tr>0)
	  {
		 var newnum=shoppingAmount+eval(me);
	  }
	  else{
		 var newnum=shoppingAmount;
	  }
       //alert(eval(me));
       $('PAYPALAMT').value=newnum.toFixed(2)
       setsession(servicename, eval(me))
      // alert($('PAYPALAMT').value);
    }

    function setsession(shippingservice, amt)
    {
      var url=SITE_URL+'shopping/setshipserviceinsession/?srvice='+shippingservice+'&amount='+amt;
      new Ajax.Updater(
							    "",
							    url, 
							    {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', ""]}
				      );	
    }
    
    

    function getBrowserInfo()
    {
	    if (checkIt('konqueror')) {
		    browser = "Konqueror";
		    OS = "Linux";
	    }
	    else if (checkIt('safari')) browser 	= "Safari"
	    else if (checkIt('omniweb')) browser 	= "OmniWeb"
	    else if (checkIt('opera')) browser 		= "Opera"
	    else if (checkIt('webtv')) browser 		= "WebTV";
	    else if (checkIt('icab')) browser 		= "iCab"
	    else if (checkIt('msie 6.0')) browser 		= "Internet Explorer 6.0"
	    else if (checkIt('msie 7.0')) browser 		= "Internet Explorer 7.0"
		else if (checkIt('msie 8.0')) browser 		= "Internet Explorer 8.0"
		else if (checkIt('msie 9.0')) browser 		= "Internet Explorer 9.0"
	    else if (!checkIt('compatible')) {
		    browser = "Netscape Navigator"
		    version = detect.charAt(8);
	    }
	    else browser = "An unknown browser";

	    if (!version) version = detect.charAt(place + thestring.length);

	    if (!OS) {
		    if (checkIt('linux')) OS 		= "Linux";
		    else if (checkIt('x11')) OS 	= "Unix";
		    else if (checkIt('mac')) OS 	= "Mac"
		    else if (checkIt('win')) OS 	= "Windows"
		    else OS 								= "an unknown operating system";
	    }
    }

    function checkIt(string) {
	    place = detect.indexOf(string) + 1;
	    thestring = string;
	    return place;
    }

/*-----------------------------------------------------------------------------------------------*/
		 
		var Base64 = {
		 
			// private property
			_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
		 
			// public method for encoding
			encode : function (input) {
				var output = "";
				var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
				var i = 0;
		 
				input = Base64._utf8_encode(input);
		 
				while (i < input.length) {
		 
					chr1 = input.charCodeAt(i++);
					chr2 = input.charCodeAt(i++);
					chr3 = input.charCodeAt(i++);
		 
					enc1 = chr1 >> 2;
					enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
					enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
					enc4 = chr3 & 63;
		 
					if (isNaN(chr2)) {
						enc3 = enc4 = 64;
					} else if (isNaN(chr3)) {
						enc4 = 64;
					}
		 
					output = output +
					this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
					this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
		 
				}
		 
				return output;
			},
		 
			// public method for decoding
			decode : function (input) {
				var output = "";
				var chr1, chr2, chr3;
				var enc1, enc2, enc3, enc4;
				var i = 0;
		 
				input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
		 
				while (i < input.length) {
		 
					enc1 = this._keyStr.indexOf(input.charAt(i++));
					enc2 = this._keyStr.indexOf(input.charAt(i++));
					enc3 = this._keyStr.indexOf(input.charAt(i++));
					enc4 = this._keyStr.indexOf(input.charAt(i++));
		 
					chr1 = (enc1 << 2) | (enc2 >> 4);
					chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
					chr3 = ((enc3 & 3) << 6) | enc4;
		 
					output = output + String.fromCharCode(chr1);
		 
					if (enc3 != 64) {
						output = output + String.fromCharCode(chr2);
					}
					if (enc4 != 64) {
						output = output + String.fromCharCode(chr3);
					}
		 
				}
		 
				output = Base64._utf8_decode(output);
		 
				return output;
		 
			},
		 
			// private method for UTF-8 encoding
			_utf8_encode : function (string) {
				string = string.replace(/\r\n/g,"\n");
				var utftext = "";
		 
				for (var n = 0; n < string.length; n++) {
		 
					var c = string.charCodeAt(n);
		 
					if (c < 128) {
						utftext += String.fromCharCode(c);
					}
					else if((c > 127) && (c < 2048)) {
						utftext += String.fromCharCode((c >> 6) | 192);
						utftext += String.fromCharCode((c & 63) | 128);
					}
					else {
						utftext += String.fromCharCode((c >> 12) | 224);
						utftext += String.fromCharCode(((c >> 6) & 63) | 128);
						utftext += String.fromCharCode((c & 63) | 128);
					}
		 
				}
		 
				return utftext;
			},
		 
			// private method for UTF-8 decoding
			_utf8_decode : function (utftext) {
				var string = "";
				var i = 0;
				var c = c1 = c2 = 0;
		 
				while ( i < utftext.length ) {
		 
					c = utftext.charCodeAt(i);
		 
					if (c < 128) {
						string += String.fromCharCode(c);
						i++;
					}
					else if((c > 191) && (c < 224)) {
						c2 = utftext.charCodeAt(i+1);
						string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
						i += 2;
					}
					else {
						c2 = utftext.charCodeAt(i+1);
						c3 = utftext.charCodeAt(i+2);
						string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
						i += 3;
					}
				}
		 
				return string;
			}
		 
		}	

	
	
	getargs=function(){
		var state=document.getElementById('UsercreditcardsState').value;
		var country=document.getElementById('UsercreditcardsCountry').value;
		document.getElementById('UsercreditcardsCity').className='txtbox03';
		var field='Usercreditcards';
		new Ajax.Autocompleter('UsercreditcardsCity', 'UsercreditcardsCity_autoComplete', SITE_URL+'user/autocity/'+country+'/'+state+'/'+field,{});
	}
	
	
	function submitForm(frm)
	{
		if((typeof( frm ) == "string" ) )
		{
			var frm = $(frm);
		}
		else
		{
			var frm = frm;	
		}
		frm.submit();
	}
	
	function confirm_and_submitForm(frm, msg)
	{
		if(!confirm(msg))
		{
			return false;
		}
		if((typeof( frm ) == "string" ) )
		{
			var frm = $(frm);
		}
		else
		{
			var frm = frm;	
		}
		frm.submit();
	}
	
	function confirm_and_send(url, msg)
	{
		if(!confirm(msg))
		{
			return false;
		}
		
		window.location.href=url;
	}
	
	
	function onlyNumbers(e)
	{
		var keynum;
		var keychar;
		var numcheck;
		if(e.keyCode == 8 || e.keyCode == 13 || e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 46 || e.keyCode == 116 )
		{
			return String.fromCharCode(keynum);
		}
		if(window.event) // IE
		{
			keynum = e.keyCode;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
		keychar = String.fromCharCode(keynum);
		numcheck = /\d/;
		return numcheck.test(keychar);
	}
	
	function updateshipservice(ctr,qty)
	{
	  if(isNaN($('printsizeqty_'+ctr).value))
	  {
		  $('printsizeqty_'+ctr).value = 0;
	  }
	  if(parseInt(qty)>0 )
	  {
		var url=SITE_URL+'shopping/changeinqty/'+ctr+'/'+qty;
		new Ajax.Updater(
							"",
							url, 
							{asynchronous:true, evalScripts:true, requestHeaders:['X-Update', ""]}
						);
	  }
	}
	
	function updateTotal4Item(e, ctr, qty, price)
	{
		var ttl = qty * price;
		ttl = ttl.toFixed(2);
		$('total4Item_'+ctr).innerHTML = ttl;
		if(isNaN($('printsizeqty_'+ctr).value))
		{
		  $('printsizeqty_'+ctr).value = 0;
		}
		if($('printsizeqty_'+ctr).value<=0)
		{
			$('removeChk'+ctr).checked=true;
		}else
		{
			$('removeChk'+ctr).checked=false;
		}
		//alert(parseInt(qty));
		if(parseInt(qty)>0 )
		{
		  var url=SITE_URL+'shopping/changeinqty/'+ctr+'/'+qty;
		  new Ajax.Updater(
							"",
							url, 
							{asynchronous:true, evalScripts:true, requestHeaders:['X-Update', ""]}
						);
		  updateShoppingCartTotals();
		}
	}
	function uncheckRemoveChk( ctr )
	{
		if($('printsizeqty_'+ctr)!=null)
		{
			if($('printsizeqty_'+ctr).value<=0)
			{
				$('removeChk'+ctr).checked=true;
			}
		}
	}
	
	function updateShoppingCartTotals()
	{
		
		
		var subTotal = new Number(0);
		var totalitems = $('totalitems').value;
		for(i=1;i<=totalitems;i++)
		{
			var t = $('total4Item_'+i).innerHTML
			var myNum=new Number(t);
			subTotal = subTotal + myNum;
		}
		
		$('subTotal').innerHTML=subTotal.toFixed(2);
		
		var srv = $('shippingservice')
		if (srv!==null && srv !='undefined' )
		{
			if (srv.selectedIndex>=0)
			{
			   var s=srv.options[srv.selectedIndex].text;
			}
		}
		
		var DCTotal = $('DCAmount')
		if (DCTotal!==null && DCTotal !='undefined' )
		{
			var DCAmount = new Number(DCTotal.innerHTML).toFixed(2);
		}
		else
		{
		  var DCAmount = new Number(0);
		}
		
		//LOWEST_SHIPPING_PRICE = s.substr(s.indexOf("|") + 1);
		
		LOWEST_SHIPPING_PRICE = ship_rates[ $('shippingservice').value ];
		
		if(LOWEST_SHIPPING_PRICE<0)
		{
		 LOWEST_SHIPPING_PRICE=0;
		}
		
		//$('fedexTotal').innerHTML = $('fedexTotalHidden').value;
		
		//$('totalwithfedex').innerHTML = (subTotal + new Number($('fedexTotal').innerHTML)).toFixed(2)
		if($('shippingservice').value=='')
		{
		    LOWEST_SHIPPING_PRICE = 0;
		}else
		{
		    //setsession($('shippingservice').value);
		}
		//if(LOWEST_SHIPPING_PRICE)
		$('totalwithfedex').innerHTML = ((subTotal - DCAmount) +  new Number(LOWEST_SHIPPING_PRICE) ).toFixed(2)
		
		
		var url=SITE_URL+'shopping/shipserviceinsessionCart/?srvice='+$('shippingservice').value+'&amount='+LOWEST_SHIPPING_PRICE;
		new Ajax.Updater(
							"",
							url, 
							{asynchronous:true, evalScripts:true, requestHeaders:['X-Update', ""]}
						);
		
		
	}
	
	function checkShoppinfCartForm(redirectTo)
	{
		var totalitems = $('totalitems').value;
		var itemsRemoved = 0;
		for(i=1;i<=totalitems;i++)
		{
			if ($('removeChk'+i).checked==true)
			{
				itemsRemoved++;
			}
		}
		
		if(itemsRemoved>0)
		{
			if(itemsRemoved==totalitems){itemsRemoved='All';}
			if(!confirm("Are you sure you want to remove "+itemsRemoved+" items from the Cart?"))
			{
				return false;
			}
		}
		//alert(redirectTo);
		$('redirectTo').value = redirectTo;
		$('shoppingCart').submit();
	}
	
	function updatewithformobserve(update, url, frmtoObserv)
	{
		if(url=='shopping/shippingrates/' || url=='shopping/fedexrate/')
		{
			$(update).innerHTML='<img src="../../img/loader4.gif">';
		}
		var a = new Ajax.Updater(
							update,
							url, 
							{asynchronous:true, evalScripts:true, parameters:Form.serialize(frmtoObserv), requestHeaders:['X-Update', update]}
						);
	}
	
	function custome_updater(update, url)
	{
		new Ajax.Updater(
							update,
							url, 
							{
                                asynchronous:true,
                                evalScripts:true,
                                requestHeaders:['X-Update', update],
                                onSuccess: function(transport) {
                                }
                            }
						);
	}
	
   
	
	function getFedexRates(update, url, frmtoObserv)
	{
        
		//SITE_URL=SITE_URL.replace("http:","https:");
		//alert(SITE_URL);
		
		if($('fedexCountry').value == '')
		{
			window.location.href=SITE_URL+'shopping/cart/?msg=3&c='+$('fedexCountry').value+'&z='+$('zipcode').value;
			//alert("Please Select destination country.")			
			return false;
		}
		//if($('zipcode').value == '')
		//{
		//	window.location.href=SITE_URL+'shopping/cart/?msg=4&c='+$('fedexCountry').value+'&z='+$('zipcode').value;
			//alert("Please enter Zip?Postal code.")
		//	return false;
		//}
		//if($('fedexCountry').value!="" && $('zipcode').value!="")
		
        $('totalwithfedex').innerHTML = preloader();

		if($('fedexCountry').value!="")
		{
			xmlHttp1=GetXmlHttpObject();
			if($('zipcode').value!="")
			{
			   var zp = $('zipcode').value;
			}else{
			   var zp = 0;
			}
			
			var url1=SITE_URL+"shopping/checkpostalcode/"+zp+"/"+$('fedexCountry').value;
			//alert(url1);
			xmlHttp1.open("GET",url1,false);
			xmlHttp1.send(null);
			
			if(parseInt(xmlHttp1.responseText)==0)
			{
			   window.location.href=SITE_URL+'shopping/cart/?msg=2&c='+$('fedexCountry').value+'&z='+$('zipcode').value;
			}
			if(parseInt(xmlHttp1.responseText)==20) // 20 means fedex failed to provide rates.
			{
			   window.location.href=SITE_URL+'shopping/cart/?msg=20&c='+$('fedexCountry').value+'&z='+$('zipcode').value;
			}
		}
		
		var v=$('shippingservice').value;
		s='<a href="javascript:;" onclick="showhippingdetails(true);">Shipping Details</a>';
		if($('fedexCountry').value == 'US')
		{
			//$('shippingservicescontainer').innerHTML = usa_shipping_options;
			s=s+'<span style="display: none;" id="0">Get free shipping on orders of $'+uspsfreeamount+' or more. Available only for orders shipping to a US address via USPS Priority Mail.</span><span class="forUSA"><a href="javascript:;" onmouseover=\'TagToTip("0", BALLOON, true, ABOVE, true, WIDTH, 260, PADDING, 8, TEXTALIGN, "justify", OFFSETX, -17)\' onmouseout="UnTip()">FREE shipping on US orders of $'+uspsfreeamount+' or more</a></span>';
			
		}
		else
		{
			//$('shippingservicescontainer').innerHTML = international_shipping_options;
		}
		$('shippingservice').value=v;
		$('shippingservicescontainer').style.display="";
		$('shippingdetailslinkcontainer').innerHTML=s;
		//$('uspsfree').innerHTML='<a href="#" title="FREE shipping on US orders of $'+uspsfreeamount;+' or more">FREE shipping on US orders of $'+uspsfreeamount;+' or more</a>';
		
		
		$('shippingservicescontainerbeforetext').style.display="none";

		if($('shippingservice').value == '' || true)
		{
			url = SITE_URL+'shopping/shippingrates/';
			updatewithformobserve(update, url, frmtoObserv);
			//alert("Please select carrier service.")
			
			return false;
		}
		else
		{
			
			updatewithformobserve(update, url, frmtoObserv);
		}
		_body_onunload();
		
	}
	function changefedexTotalText()
	{
		if($("shippingservice").value=='USPS')
		{
			$('fedexTotalText').innerHTML = "USPS Rate";
		}
		else
		{
			$('fedexTotalText').innerHTML = "Fedex Rate";
		}
	}
	function updateLowestShippingCost()
	{
		$('shippingservice').value = LOWEST_SHIPPING_SERVICE;
		$('fedexTotal').innerHTML = LOWEST_SHIPPING_PRICE;
		
	}
	
	function showhippingdetails(show)
	{
	   
		if(show==true)
		{
			if($('fedexCountry').value == '')
			{
				alert("Please Select destination country.")
				return false;
			}
			$('lightBox').style.display='';
			
			if($('fedexCountry').value == 'US')
			{
				$('shiptime').innerHTML = usa_shipping_time;
			}
			else
			{
				$('shiptime').innerHTML = international_shipping_time;
			}
			//alert(document.body.clientHeight);
			$('lightBox').style.top=(document.body.clientHeight-255) +"px";
		}
		else
		{
			$('lightBox').style.display='none'
		}
	}
	function showcheckoutbox(show)
	{
		if(show==true)
		{
			$('lightBox01').style.display=''
			$('lightBox01').style.top=(document.body.clientHeight-505) +"px";
		}
		else
		{
			$('lightBox01').style.display='none'
		}
	}
	function largeView(crsobj, obj, view, c, man, imgn)
	{
		
		var paras = $A(document.getElementsByClassName('pcNormalBig01'));
		paras.each(Element.hide);
		
		
		getBrowserInfo();
		if(obj!='' && obj != null){refobj=obj}else{obj=refobj}
		if(c!=0 && c != null){largeViewCounter=c}
		if(man!='' && man != null){master_asset_number=man}
		if(imgn!='' && imgn != null){image_number=imgn}
		if(crsobj!='' && crsobj != null){crossobj=crsobj}
		var scrld = Number(document.getElementById("t").innerHTML);
		
		//crossobj=(domII)?document.getElementById("largeImage").style : ieII? document.all.largeImage : document.largeImage;
		var offsetLeft=0;
		var offsetTop=0;
		//alert(obj.offsetParent.offsetLeft);
		var extra_pixels_for_higher_resolutions=0;
		if(view!='none')
		{
			if(browser == "Internet Explorer 7.0" || browser == "Internet Explorer 6.0")
			{
				if(window.screen.availWidth>1024){
					extra_pixels_for_higher_resolutions=124;
				}
				offsetLeft = (obj.offsetParent.offsetLeft + obj.parentNode.offsetLeft)+extra_pixels_for_higher_resolutions + 'px';
				offsetTop = (obj.offsetParent.offsetTop + obj.parentNode.offsetTop)+585 - scrld + 'px';
			}
			else
			{
				offsetLeft = (obj.offsetLeft )-10 + 'px';
				offsetTop = (obj.offsetTop )-(10+scrld ) + 'px';
			}
			//alert("left = "+offsetLeft+" \ top = "+offsetTop)
			crossobj.style.left = offsetLeft;
			crossobj.style.top = offsetTop;
		}
		crossobj.style.display = view;
		
		
		//document.getElementById('bigviewlnkI').href = document.getElementById('bigviewlnk'+c).href;
		
		//$('bigviewlnkI').href = '/criticalpast/products/bigview/'+master_asset_number+'/'+image_number;
		//$('bigviewlnkII').href = '/criticalpast/products/bigview/'+master_asset_number+'/'+image_number;
		//$('thumbimgI').src = $('thumbimg'+c).src;
		//$('photobuylnkI').href = '/criticalpast/products/photobuydetails/'+master_asset_number+'/'+image_number;		//
		
		
	} 
	
	
	
	function scrollTheScroller2()
	{
		pollID = setInterval("scrollTheScroller2()",500);
	}


	  var tm;
	  var flag=0;
	  var mainscrld = 0;
	function scrollTheScroller(r)
	{
		var min1=0;
		var max1=0;
		var mod1=29;
		var mod2=130;
		
		var min1=0;
		var min11=1;
		var max1=0;
		var max11=20;
		
		//$('picContainer').style.overflow = 'auto';
		
		document.getElementById("t").innerHTML = document.getElementById("picContainer").scrollTop;
		
		
		var scrld = Number(document.getElementById("t").innerHTML);
		if (scrld==0){$('count').innerHTML="1-20";return;}
		if (scrld>0 && scrld<mod1)
		{
			min1=1;
			max1=20;
		}
		if ((scrld % mod1 ) <= 0){
			min1=parseInt(scrld / mod1 * 5+1 );
			max1=parseInt(scrld / mod1 * 5 +15 );
			min11=parseInt(parseInt(scrld / mod2) * 5+1 );
			max11=parseInt(parseInt(scrld / mod2) * 5+25);
			$('scrolldetails').innerHTML += "<br> in ---[ FIRST COND ] --- " ;
			
		}
		if(imagePageTotal>parseInt(parseInt(scrld / mod2) * 5 +20))
		{
			if ((scrld % mod1) > 0 && scrld>mod1)
			{
				min1=parseInt(parseInt(scrld / mod1) * 5+1 );
				max1=parseInt(parseInt(scrld / mod1) * 5+20);
				min11=parseInt(parseInt(scrld / mod2) * 5+1 );
				max11=parseInt(parseInt(scrld / mod2) * 5+25);
				$('scrolldetails').innerHTML += "<br> in ---[ SECOND COND ] --- " ;
			}
		}
		else
		{
			//alert(imagePageTotal)
			//alert(parseInt(parseInt(scrld / mod1) * 5 +20))
			$('scrolldetails').innerHTML += "<br> in ---[ ELSE of SECOND COND ] --- " ;
			if ((scrld % mod1) > 0 && scrld>mod1)
			{
				min1=parseInt(parseInt(scrld / mod1) * 5+1 );
				min11=parseInt(parseInt(scrld / mod2) * 5 - 4 );
				max1=imagePageTotal;
				max11=imagePageTotal;
				$('scrolldetails').innerHTML += "<br> in ---[ ELSE of SECOND COND IN SUB CONDITION ] --- " ;
			}
		}
		if(max11>imagePageTotal)
		{
		 max11=imagePageTotal;
		}
		
		$('count').innerHTML=min11+'-'+max11;
		$('scrolldetails').innerHTML += "<br>  Min1 = " + min1 +"    =   Max1 = " + max1 ;
		$('scrolldetails').innerHTML += "<br>  Min11 = " + min11 +"    =   max11 = " + max11 ;
		//alert(flag);
		//if(flag==0)
		//{
		 //$('picContainer').style.overflow='hidden';
		 update_container(min11, max11, scrld);
		 //update_container(min11, min11+15, scrld);
		 
		 
		 //check_all_loding_images(min11, min11);
		 flag=1;
		 //mainscrld = scrld
		 //alert("request sent");
		//}
		//else
		//{
		// document.getElementById("picContainer").scrollTop = mainscrld;
		//}
		
		//setTimeout(function(){flag=0; }, 2000);
		//update_container(min1, max1);
		//check_all_loding_images(min1, min1+30);
	}
	
	
	
	function update_container(min1, max1, scrld)
	{
		var start = 0;
		if(imagePageTotal<max1){
			max1=imagePageTotal;
		}
		var end = max1+10;
		var g=0;
		if(imagePageTotal<end){
			end=imagePageTotal;
		}
		
		
		/* OLD LOOP
		for (g=16;g<=max1;g++)
		{
			if($('loader_image_'+g)==null)
			{
				//alert(g);
			}
			else
			{
				if($('loader_image_'+g).alt=='transparent')
				{
					if(start==0)start=g;
					$('loader_image_'+g).src=lodingImage;
					$('loader_image_'+g).alt = "loading";
				}
			}
		}
		*/
		for (g=parseInt(max1)-45;g<=parseInt(max1)+5;g++)
		{
			if($('loader_image_'+g)==null)
			{
				//alert(g);
			}
			else
			{
				if($('loader_image_'+g).alt=='transparent' || $('loader_image_'+g).alt=='loading')
				{
					 if(start==0)start=g;
					 if($('loader_image_'+g).alt=='transparent')
					 {
						$('loader_image_'+g).src=lodingImage;
						$('loader_image_'+g).alt = "loading";
					 }
				}
			}
		}
		//alert(start);
		if(start>0 )
		{
			//if(mainscrld==100)  ///  this was used for testing purpose for loading image issue [not loaaded at all]
			//{
			   var url=site_url+'products/loadimages/?master_asset_number='+master_asset_number+'&start='+start+'&end='+end+'&scrld='+scrld;
			   setTimeout("updatewithformobserve('picContainer2', '" + url + "','dumform')", 1000);
			   //updatewithformobserve('picContainer2', url,'dumform');
			//}
		}
		
	}
	
	function update_all_image_container(min1, max1)
	{
		var added=0;
		flag=0;
		for(min1;min1<=max1;min1++)
		{
			if ($('image_container_'+min1) != null && $('image_container_new_'+min1) != null)
			{
				if($('loader_image_'+min1).alt=='loading')
				{
					$('image_container_'+min1).innerHTML = $('image_container_new_'+min1).innerHTML;
					added++;
				}
			}
		}
		if(added>0)
		{
			//initialize();
		}
		check_all_loding_images(min1, max1);
		// picContainer
	}
	
	function check_all_loding_images(min1, max1)
	{
		check_all_loding_images1();
		return false;
		var added=0;
		for(min1;min1<=max1;min1++)
		{
			if ($('loader_image_'+min1) != null)
			{
				if($('loader_image_'+min1).alt=='loading')
				{
					var url=site_url+'products/loadimages/?master_asset_number='+master_asset_number+'&start='+min1+'&end='+max1;
					updatewithformobserve('picContainer2', url,'dumform');
					return false;
				}
			}
		}
		return false;
	}
	function check_all_loding_images1()
	{
		var scrld = Number(document.getElementById("t").innerHTML);
		if (scrld>30)
		{
			var min1=scrld/30;
			var max1=min1+50;
		}else
		{
			return false;
		}
		if(imagePageTotal<max1){
			max1=imagePageTotal;
		}
		
		var added=0;
		//
		
		for(min1;min1<=max1;min1++)
		{
			if ($('loader_image_'+min1) != null)
			{
				if($('loader_image_'+min1).alt=='loading')
				{
					var url=site_url+'products/loadimages/?master_asset_number='+master_asset_number+'&start='+min1+'&end='+max1;
					updatewithformobserve('picContainer2', url,'dumform');
					//alert(min1+" "+max1);
					return true;
				}
			}
			else
			{
			//alert("these ar null     " + min1+" "+max1);	
			}
		}
		return true;
	}
	
	function hideAllLargeView(ctrl)
	{
		var i=0;
		
		for(i=1;i<=ctrl;i++)
		{
			if($('largeImage'+i) == null ) return;
			$('largeImage'+i).style.display = 'none';
		}
	}
	
	function creditCardShow()
	{
		if($('creditcard').checked==true)
		{
			//alert('hello');
			$('cc_id').style.display='';
			$('paypal_id').style.display='none';
			$('googleCheckoutButton').style.display='none';
			$('loading').style.display='';
			
		}
		else if($('google').checked==true)
		{
			$('googleCheckoutButton').style.display='';
			$('cc_id').style.display='none';
			$('paypal_id').style.display='none';
			$('loading').style.display='none';
		}
		else if($('paypal').checked==true)
		{
			$('paypal_id').style.display='';
			$('googleCheckoutButton').style.display='none';
			$('cc_id').style.display='none';	
			$('loading').style.display='none';
		}
	}
	
	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
		{
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
		  // Internet Explorer
		  try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}
	
   
	
	function guestemailvalidation(formname)
	{
		 
		 
		 if($('ownFedexSON') != null && $('ownFedexSON') != 'undefined')
	     {
			
		    if($('ownFedexSON').checked==true )
		    {
			
		       if($('fedexAcNumber').value=="" || isInteger($('fedexAcNumber').value)==false)
		       {
			      str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please enter a valid fedex account number</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				  $('errormessage').innerHTML=str;
				  scroll(0,0);
			      return false;
		       }
		       else if($('fedexAcNumber').value!="" && ($('Frecipient').checked==false && $('Fthirdparty').checked==false))
		       {
			      	str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please select fedex account owner</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				    $('errormessage').innerHTML=str;
				    scroll(0,0);
			       	return false;
		       }
			
		    }
		 }
		 if($('ownFedexPON') != null && $('ownFedexPON') != 'undefined')
	     {
			
		    if($('ownFedexPON').checked==true )
		    {
			
		       if($('fedexAcNumber').value=="" || isInteger($('fedexAcNumber').value)==false)
		       {
			      str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please enter a valid fedex account number</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				  $('errormessage').innerHTML=str;
				  scroll(0,0);
			      return false;
		       }
		       else if($('fedexAcNumber').value!="" && ($('Frecipient').checked==false && $('Fthirdparty').checked==false))
		       {
			      	str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please select fedex account owner</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				    $('errormessage').innerHTML=str;
				    scroll(0,0);
			       	return false;
		       }
			
		    }
			//else
			//{
			//   alert('PON checkeds  else');
			//}
		 }
		 
		 //alert(1);
		 //return false;
		 
		 if($('GuestusersEmail')!=null &&  $('GuestusersCemail')!=null)
		 {
			if (xmlHttp==null)
			{
                alert ("Your browser does not support AJAX");
                return false;
			}
			str=$('GuestusersEmail').value+","+$('GuestusersCemail').value;
			str=Base64.encode(str);
			if(formname=='paypalpayment' || formname=='payment')
				var url=SITE_URL+"user/guestemailvalidation/"+str+"/payment";
			else
			    var url=SITE_URL+"user/guestemailvalidation/"+str;
			//alert(url);
			xmlHttp.open("GET",url,false);
			xmlHttp.send(null);
			if(xmlHttp.responseText=="1")
			{
				  var urlGC=SITE_URL+"shopping/gcButCh/";
				  //custome_updater("CheckOut1GoogleCheckoutButton", urlGC)
				  //alert(urlGC);
				  new Ajax.Request(urlGC, {
					 method: 'get',
					 onSuccess: function(transport) {
						var notice = $('CheckOut1GoogleCheckoutButton');
						notice.innerHTML = transport.responseText;
						//$(formname).submit();
					 }
				   });
				  var urlGC=SITE_URL+"shopping/bturl/";
				  //alert(urlGC);
				  new Ajax.Request(urlGC, {
					 method: 'get',
					 onSuccess: function(transport) {
						var notice = $('tr_dataID');
						//alert(notice.value);
						notice.value = transport.responseText;
						//alert(notice.value);
						$(formname).submit();
					 }
				   });
			}
			else
			{
			   alert(xmlHttp.responseText);
			   return false;
			}
		 }
		 else
		 {
			$(formname).submit();
		 }
		 return false;
		 return true;
	}
	
	function ter(formname)
	{
	  var vGuestusersEmail = $('GuestusersEmail').value
	  $('cpAccountdisplay').style.display='block';
	  $('gustemailid').innerHTML=vGuestusersEmail;
	  $('cpAccountinput').style.display='none';
	  $('cpAccountinput').innerHTML="";
	  
	  var urlGC=SITE_URL+"shopping/bturl/";
	  alert(urlGC);
	  new Ajax.Request(urlGC, {
		 method: 'get',
		 onSuccess: function(transport) {
			var notice = $('tr_dataID');
			alert(notice.value);
			notice.value = transport.responseText;
			alert(notice.value);
			$(formname).submit();
		 }
	   });
	  
	}
	
	function changeBTTRDATA()
	{
		var tr_dataID =new String("");
		if($('ownFedexSON') != null || $('ownFedexPON') != null)
	    {
		    if($('ownFedexSON').checked==true || $('ownFedexPON').checked==true)
		    {
		       if($('fedexAcNumber').value=="" || isInteger($('fedexAcNumber').value)==false)
		       {
		       }
			   else
			   {
				  tr_dataID += "fedexacnov=" + $('fedexAcNumber').value;
			   }
		       if($('fedexAcNumber').value!="" && ($('Frecipient').checked==false && $('Fthirdparty').checked==false))
		       {
		       }
			   else
			   {
				  if($('Frecipient').checked==true)
				  {
					tr_dataID += "&fedexacownerv=recipient";
				  }
				  else if($('Fthirdparty').checked==true)
				  {
					tr_dataID += "&fedexacownerv=thirdparty";
				  }
			  }
			  
			  var args="";
			  var f="updateTRDATA";
			 
			  tr_dataID=Base64.encode(tr_dataID);
			  f=Base64.encode(f);
			  
			  var str=f+"__"+tr_dataID;
			  url=SITE_URL+'shopping/wrapperF/'+str;
			  
			  new Ajax.Request(url, {
				method: 'get',
				onSuccess: function(transport) {
				   var notice = $('tr_dataID');
				   alert(notice.value);
				   notice.value = transport.responseText;
				   alert(notice.value);
				   $(formname).submit();
				}
			  });
			  
		    }
		}
	}
	
	function checkCheckout2Form(frm, chkfor)
	{
	    
		var d = new Date();
		
	    if($('ownFedexSON') != null || $('ownFedexPON') != null)
	    {
		    if($('ownFedexSON').checked==true || $('ownFedexPON').checked==true)
		    {
			
		       if($('fedexAcNumber').value=="" || isInteger($('fedexAcNumber').value)==false)
		       {
			      str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please enter a valid fedex account number</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				  $('errormessage').innerHTML=str;
				  scroll(0,0);
			      return false;
		       }
			   else
			   {
				  
			   }
		       if($('fedexAcNumber').value!="" && ($('Frecipient').checked==false && $('Fthirdparty').checked==false))
		       {
			      	str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please select fedex account owner</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				    $('errormessage').innerHTML=str;
				    scroll(0,0);
			       	return false;
		       }
			   else
			   {
				  if($('Frecipient').checked==true)
				  {
					
				  }
				  else if($('Fthirdparty').checked==true)
				  {
					
				  }
			   }
			
		    }
		}
		
		//alert($("checkout2").action)
		if (
			  ($('UsercreditcardsId') != null && $('UsercreditcardsId').value == -11) ||
			  (is_guest == 1)
		   )
		{
		  if($('UsercreditcardsCcType').value=="0")
		  {
			  str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please select Credit Card Type.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  //alert('Credit Card Type Field Cannot be left blank');
			  return false;
		  }
		  else if($('UsercreditcardsCcNumber').value=="")
		  {
			  str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Credit Card Number cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  //alert('Credit Card Number Field Cannot be left blank');
			  return false;
		   }
		   else if($('UsercreditcardsYearYear').value<=0 || $('UsercreditcardsMonth').value<=0)
		   {
			  str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please specify a valid card expiration date.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  return false;
		    }
		    else if($('UsercreditcardsYearYear').value < d.getUTCFullYear() )
		    {
			  str='<div id="errorBox" style="height:auto;width:550px"  ><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please specify a valid card expiration date.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  return false;
		    }
		    else if($('UsercreditcardsYearYear').value <= d.getUTCFullYear() && $('UsercreditcardsMonth').value < ( d.getMonth() + 1)  )
		    {
			  str='<div id="errorBox" style="height:auto;width:550px"  ><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please specify a valid card expiration date.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  return false;
		    }
		   
		   
		  else if($('UsercreditcardsCcSecurityCode') != null &&  $('UsercreditcardsCcSecurityCode').value=="")
		  {
			str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Card Security Code cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			  $('errormessage').innerHTML=str;
			  scroll(0,0);
			  //alert('Credit Card Security Code Field Cannot be left blank');
			  return false;
		  }
		   else if($('UsercreditcardsCcOwner').value=="")
		  { 
			   str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>"Name on Card" cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			   $('errormessage').innerHTML=str;
			   scroll(0,0);
			   //alert('Credit Card Owner name Field Cannot be left blank');
			   return false;
		  }
		}
		if($('UsercreditcardsCcSecurityCode') != null &&  $('UsercreditcardsCcSecurityCode').value=="")
		{
		  str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Card Security Code cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			$('errormessage').innerHTML=str;
			scroll(0,0);
			//alert('Credit Card Security Code Field Cannot be left blank');
			return false;
		}
		
		  
		  
		if($('GuestusersEmail')!=null &&  $('GuestusersCemail')!=null)
		{
		  
			if($('GuestusersEmail').value != $('GuestusersCemail').value )
			{ 
				 str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Your two entries for "Email Address" do not match.  Please try again.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				 $('errormessage').innerHTML=str;
				 scroll(0,0);
				 //alert('Credit Card Owner name Field Cannot be left blank');
				 return false;
			}
		  
				if (xmlHttp==null)
				{
				  alert ("Your browser does not support AJAX");
				  return false;
				}
				str=$('GuestusersEmail').value+","+$('GuestusersCemail').value;
				var vGuestusersEmail = $('GuestusersEmail').value
				
				
				str=Base64.encode(str);
				
				var url=SITE_URL+"user/guestemailvalidation/"+str;
				//alert(url);
				
				new Ajax.Request(url, {
					 method: 'get',
					 onSuccess: function(transport) {
						//alert(transport.responseText);
						if(transport.responseText == "1")
						{
							//alert('going to ter()');
							$('cpAccountdisplay').style.display='block';
							$('gustemailid').innerHTML=vGuestusersEmail;
							$('cpAccountinput').style.display='none';
							$('cpAccountinput').innerHTML="";
							
							var urlGC=SITE_URL+"shopping/bturl/";
							//alert(urlGC);
							new Ajax.Request(urlGC, {
							   method: 'get',
							   onSuccess: function(transport) {
								  var notice = $('tr_dataID');
								  //alert(notice.value);
								  notice.value = transport.responseText;
								  //alert(notice.value);
								  $("checkout2").submit();
								  return true; // returning for bt url submit
								  $(formname).submit();
								  return true; // returning for bt url submit
							   }
							 });
							
						}
						else
						{
							//alert("ERROR of guestemailvalidation");
							
							str = '<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>' + transport.responseText.replace("|","<br>")+'</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
							//alert(str);
							$('errormessage').innerHTML = str;
							//alert(str);
							scroll(0,0);
							//alert(xmlHttp.responseText);
							return false;
						}
						//alert('came from ter()');
					 }
				   });
				
				/*
				xmlHttp.open("GET",url,false);
				xmlHttp.send(null);			
				if(xmlHttp.responseText=="1")
				{
					$('cpAccountdisplay').style.display='block';
					$('gustemailid').innerHTML=vGuestusersEmail;
					$('cpAccountinput').style.display='none';
					$('cpAccountinput').innerHTML="";
				}
				else
				{
					str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>'+xmlHttp.responseText.replace("|","<br>")+'</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				    $('errormessage').innerHTML=str;
					scroll(0,0);
					//alert(xmlHttp.responseText);
					return false;
				}
				*/
		}
		else
		{
		  
		  
			
			return true;
		}
		
		//alert($("tr_dataID").value);
		//changeBTTRDATA();
		//alert($("tr_dataID").value);
		//return false;
		
		//return true; // returning for bt url submit
	  
	  /*
	    
	    if($('checkinOutAsGuest').value=='0')
	    {
		    if($('UsercreditcardsId').value==0)
		    {
			    alert('Please select a credit card, or choose from one of the "Other Checkout Options".');
			    return false;
		    }
		}
		var addNewCC=0;
		if($('checkinOutAsGuest').value=='1')
		{
		    addNewCC=1;
		}
		else
		{
		    if($('UsercreditcardsId').value==-11)
		    {
		        addNewCC=1;
		    }
		}
		
		
		if(addNewCC==1)
		{
		    //if($('checkinOutAsGuest').value=='0')
			// {
			//    if($('UsercreditcardsCcName').value=="")
			//     {
			//	    str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Save Card as Field Cannot be left blank</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
			//	    $('errormessage').innerHTML=str;
			//	    scroll(0,0);
			//	    //alert('Save Card as Field Cannot be left blank');
			//	    return false;
			//    }
			//}
			 var d = new Date();
			 var curMonth = d.getMonth() + 1;
			 var curYear = d.getFullYear();

			if($('UsercreditcardsCcType').value=="0")
			{
				str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please select Credit Card Type.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				$('errormessage').innerHTML=str;
				scroll(0,0);
				//alert('Credit Card Type Field Cannot be left blank');
				return false;
			}
			else if($('UsercreditcardsCcNumber').value=="")
			{
				str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Credit Card Number cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				$('errormessage').innerHTML=str;
				scroll(0,0);
				//alert('Credit Card Number Field Cannot be left blank');
				return false;
			 }
			 else if($('UsercreditcardsYearYear').value<=0 || $('UsercreditcardsMonth').value<=0)
			 {
				str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Please specify a valid card expiration date.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				$('errormessage').innerHTML=str;
				scroll(0,0);
				return false;
			 }
			 else if($('UsercreditcardsCcSecurityCode').value=="")
			 {
				str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>Card Security Code cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				$('errormessage').innerHTML=str;
				scroll(0,0);
				//alert('Credit Card Security Code Field Cannot be left blank');
				return false;
			 }
			 else if($('UsercreditcardsCcOwner').value=="")
			 { 
		          str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>"Name on Card" cannot be blank.</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				  $('errormessage').innerHTML=str;
				  scroll(0,0);
				  //alert('Credit Card Owner name Field Cannot be left blank');
				  return false;
			 }
			 
			 
			 else if( parseInt($('UsercreditcardsYearYear').value) <= parseInt(curYear) && parseInt($('UsercreditcardsMonth').value) < parseInt(curMonth) )
			 {
				$('UsercreditcardsYearYear').value+'-'+$('UsercreditcardsMonth').value
		          str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p> The credit card expiration date has passed. Please enter a valid, future expiration date or use a different credit card. </p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
				  $('errormessage').innerHTML=str;
				  scroll(0,0);
				  //alert('Credit Card Owner name Field Cannot be left blank');
				  return false;
			 }
			 
			 
			 
			 {
			    if($('checkinOutAsGuest').value=='0')
			    {
				    if($('UsercreditcardsIsDefault').checked)
				    {
					    def=1;
	                }
				    else
				    {
				       def=0;
				    }
				}
				
			    
				if($('UsercreditcardsCcName') != null)
				{
				  if($('UsercreditcardsCcName').value=="")
			      {
				    s=$('UsercreditcardsCcNumber').value;
				    l=s.length;
				    sub=s.substring((l-4),l);
				    $('UsercreditcardsCcName').value= "My "+ $('UsercreditcardsCcType').value+" "+sub;
			      }
				}
				
				if($('checkinOutAsGuest').value=='1')
				{
				    //str="NA,"+$('UsercreditcardsCcType').value + ","+$('UsercreditcardsCcNumber').value+","+$('UsercreditcardsYearYear').value+'-'+$('UsercreditcardsMonth').value+","+$('UsercreditcardsCcSecurityCode').value+","+$('UsercreditcardsCcOwner').value+", 0";
				    str="NA,"+$('UsercreditcardsCcType').value + ","+$('UsercreditcardsCcNumber').value+","+$('UsercreditcardsYearYear').value+'-'+$('UsercreditcardsMonth').value+","+$('UsercreditcardsCcSecurityCode').value+","+$('UsercreditcardsCcOwner').value+", 0";
				}
				else
				{
				    str=$('UsercreditcardsCcName').value+","+$('UsercreditcardsCcType').value + ","+$('UsercreditcardsCcNumber').value+","+$('UsercreditcardsYearYear').value+'-'+$('UsercreditcardsMonth').value+","+$('UsercreditcardsCcSecurityCode').value+","+$('UsercreditcardsCcOwner').value+","+def;
				}
				
				
				
				//alert(str);
				//exit;
				
				str=Base64.encode(str);
				//xmlHttp=GetXmlHttpObject();
				if (xmlHttp==null)
				{
				  alert ("Your browser does not support AJAX");
				  return false;
				} 
				var url=SITE_URL+"shopping/addcc/"+str;					
				/*xmlHttp.onreadystatechange=function()
				{
					if(xmlHttp.readyState==4)
					{
					  alert(xmlHttp.responseText);
					}
				}
				//document.write (url);
				xmlHttp.open("GET",url,false);
				xmlHttp.send(null);				
				if(xmlHttp.responseText=="")
				{
					 return true
				}
				else
				{
					 str='<div id="errorBox"><div class="tcErrorBox"><div class="tlErrorBox"><div class="trErrorBox">&nbsp;</div></div></div><div class="bodyErrorBox"><h4>There was a problem with your entry:</h4><p>'+xmlHttp.responseText+'</p></div><div class="bcErrorBox"><div class="blErrorBox"><div class="brErrorBox">&nbsp;</div></div></div></div>';
					 $('errormessage').innerHTML=str;
					 scroll(0,0);
					 //alert(xmlHttp.responseText);
					 return false;
				}
			 }
		}
		// _body_onunload();  
		//return false;
		return true;
	  */
	}
	
	

	function shipping_copy(){
		if($('ship_copy').checked==true)
		{
			$('OrderbillingdetailsFname').value=$('OrderbillingdetailsFname1').value;
			$('OrderbillingdetailsLname').value=$('OrderbillingdetailsLname1').value;
			$('OrderbillingdetailsCompany').value=$('OrderbillingdetailsCompany1').value;
			$('OrderbillingdetailsAddress1').value=$('OrderbillingdetailsAddress11').value;
			$('OrderbillingdetailsAddress2').value=$('OrderbillingdetailsAddress21').value;
			$('OrderbillingdetailsCity').value=$('OrderbillingdetailsCity1').value;
			$('OrderbillingdetailsCountry').value=$('OrderbillingdetailsCountry1').value;
			$('OrderbillingdetailsState').value=$('OrderbillingdetailsState1').value;
			$('OrderbillingdetailsZip').value=$('OrderbillingdetailsZip1').value;
			$('OrderbillingdetailsAddressType').value='shipping';
			$('OrderbillingdetailsPhoneNo').value=$('OrderbillingdetailsPhoneNo1').value;
		}else if($('ship_copy').checked==false){
		
			$('OrderbillingdetailsFname').value='';
			$('OrderbillingdetailsLname').value='';
			$('OrderbillingdetailsCompany').value='';
			$('OrderbillingdetailsAddress1').value='';
			$('OrderbillingdetailsAddress2').value='';
			$('OrderbillingdetailsCity').value='';
			$('OrderbillingdetailsCountry').value='';
			$('OrderbillingdetailsState').value='';
			$('OrderbillingdetailsZip').value='';
			$('OrderbillingdetailsAddressType').value='shipping';
			$('OrderbillingdetailsPhoneNo').value='';
		}
	}
	
	
	
	function countit(keycode)
	{
		var wordLimit = 500;
		var formcontent=document.getElementById('TellMessage').value;
		var count=formcontent.length;
		
		if(count >499)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById('TellMessage').value=(formcontent.substr(0,499))
		}
		document.getElementById('totalChar').value=count;
		return true;
	}
	function charcount(keycode)
	{
		var wordLimit = 2500;
		var formcontent=document.getElementById('ContactMessage').value;
		var count=formcontent.length;
		
		if(count >2499)
		{
			alert('Please limit your message to '+wordLimit+' characters.')
			document.getElementById('ContactMessage').value=(formcontent.substr(0,2499))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function charcount2(keycode)
	{
		var wordLimit = 500;
		var formcontent=document.getElementById('UserAboutme').value;
		var count=formcontent.length;
		
		if(count >499)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById('UserAboutme').value=(formcontent.substr(0,499))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function charcount3(keycode)
	{
		var wordLimit = 50;
		var formcontent=document.getElementById('UserCity').value;
		var count=formcontent.length;
		
		if(count >49)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById('UserCity').value=(formcontent.substr(0,499))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function charcount4(keycode)
	{
		var wordLimit = 50;
		var formcontent=document.getElementById('UserCountry').value;
		var count=formcontent.length;
		
		if(count >49)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById('UserCountry').value=(formcontent.substr(0,499))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function charcount5(keycode)
	{
		var wordLimit = 50;
		var formcontent=document.getElementById('UserForumemail').value;
		var count=formcontent.length;
		
		if(count >49)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById('UserForumemail').value=(formcontent.substr(0,499))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function charcountDynamic(elmnt, wl)
	{
		var wordLimit = wl;
		var formcontent=$(elmnt).value;
		var count=formcontent.length;
		
		if(count >wl)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			$(elmnt).value=(formcontent.substr(0,wl))
		}
		//document.getElementById('totalChar').value=count;
		return true;
	}
	function max_chars_limit(e, limit, ctrl)
	{
	
		
		
		if(window.event) // IE
		{
			keynum = e.keyCode;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
		//alert(keynum);
	    if(keynum == 8 || keynum == 13 || keynum == 27 || keynum == 33 || keynum == 34 || keynum == 35 || keynum == 37 || keynum == 38 || keynum == 39 || keynum == 40 || keynum == 45 || keynum == 46 || keynum == 116 || keynum == 16 || keynum == 17 || keynum == 18  )
		{
			return String.fromCharCode(keynum);
		}
        
	
		var wordLimit = limit;
		var formcontent=document.getElementById(ctrl).value;
		var count=formcontent.length;

		if(count >limit-1)
		{
			alert('You cannot write more then '+wordLimit+' characters!')
			document.getElementById(ctrl).value=(formcontent.substr(0,limit-1))
			return false;
		}
		//document.getElementById(ctrl).value=count;
		return true;
	}
	function dimessage(n)
	{
	  url = SITE_URL+'admin/download_instruction/' + n;
	  if(confirm("Are you sure you want to send 'Download Instruction' email?"))
	  {
		open_window2(url, 900, 200, 'center');
	  }
	  return false;
	}
	function open_window(url,w,h)
	{
		var testwindow=window.open (url, "mywindow", "toolbar=1,menubar=1,location=1,status=1,scrollbars=1,width="+w+",height="+h+"");
		try
		{
			testwindow.moveTo(window.screen.availWidth-w,window.screen.availHeight-h);
		}catch(e){
		}
	}
	
	function open_window2(url,w,h, position)
	{
		var testwindow= window.open (url, "mywindow", "toolbar=1,menubar=1,location=1,status=1,scrollbars=1,width="+w+",height="+h+"");

		if(position=='rightbottom' || position=='bottomright')
		{
			testwindow.moveTo(window.screen.availWidth-w,window.screen.availHeight-h);
		}
		else if(position=='center')
		{
			try
			{
				testwindow.moveTo(window.screen.availWidth/2-w/2,window.screen.availHeight/2-h/2);
			}catch(e){
			}
		}
	}
	
	
	function checkPhotoBuyForm(frm)
	{
		var ttl=0;
		var total_photo_product_chk=$('total_photo_product_chk').value;
		for(i=1;i<=total_photo_product_chk;i++)
		{
			if($('photo_product_chk_'+i)!=null && $('photo_product_chk_'+i).checked == true )
			{
				ttl++;
			}
		}
		
		if(ttl<=0)
		{
			alert('Please select a product before you click "Add To Cart".')
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function birth_day_history(frm)
	{
		
		if (birth_day_history_search != 1)
		{
		  
		  frm.action = frm.action.replace("month","mn1")
		  frm.action = frm.action.replace("day","dy1")
//		  alert(frm.action)
			try {
				$('day').value = "";
				$('month').value = "";
			} catch (e) { }	
		}
	}
	
/*******SEARCH VALIDATION********/
	function searchterm(t)
	{
		if(document.getElementById('q').value=="Search over 583 videos and 81 thousand images." || document.getElementById('q').value=="")
		{
			alert("Please enter search term(s)");
			document.getElementById('q').focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	function showhide(url)
	{
		if(document.getElementById('zemanta').style.display=='none')
		{
			document.getElementById('zemanta').style.display='block';   
			document.getElementById('more').innerHTML="<li class='moreMinus'><a title='Hide' href='javascript:void(0)' onclick='showhide()'><img src='"+SITE_URL+"img/moreIcon01.gif'/>&nbsp; Less</a></li>";
		}
		else if(document.getElementById('zemanta').style.display=='block')
		{
			document.getElementById('zemanta').style.display='none';     
			document.getElementById('more').innerHTML="<li class='morePlus'><a title='Show' href='javascript:void(0)' onclick='showhide()'><img src='"+SITE_URL+"img/moreIcon.gif'/>&nbsp; More</a></li>";
		}
	}
	
	function showhidelink(url)
	{
		if(document.getElementById('zemantalink').style.display=='none')
		{
			document.getElementById('zemantalink').style.display='block';   
			document.getElementById('morelink').innerHTML="<li class='moreMinus'><a title='Hide' href='javascript:void(0)' onclick='showhidelink()'><img src='"+SITE_URL+"img/moreIcon01.gif'/>&nbsp; Less</a></li>";
		}
		else if(document.getElementById('zemantalink').style.display=='block')
		{
			document.getElementById('zemantalink').style.display='none';     
			document.getElementById('morelink').innerHTML="<li class='morePlus'><a title='Show' href='javascript:void(0)' onclick='showhidelink()'><img src='"+SITE_URL+"img/moreIcon.gif'/>&nbsp; More</a></li>";
		}
	}
	
    function showhideElement(ctrl, obj)
	{
		if($(ctrl).style.display=="")
		{
		  $(ctrl).style.display = "none";
		}
		else
		{
		  $(ctrl).style.display = "";
		}
		if(obj != null)
		{
		  $(ctrl).style.top = parseInt(obj.offsetTop) + 200 + "px";
		}
	}


	function keyPressed(obj, e)
	{
		if(e.keycode==46 || e.keycode==8)
		{
			obj.value='';
		}
	}
	function checkDates(biggerObj, smallerObj)
	{
		if(document.search.dateRange.checked==true)
		{
			bigd=$(biggerObj).value;
			smalld=$(smallerObj).value;
			if(isDate(bigd) && isDate(smalld))
			{
				
				if(bigd=='' || smalld=='') return true;
				
				bigd=bigd.split('-')
				smalld=smalld.split('-')
				
				var bigDate=new Date();
				var smallDate=new Date();
				
				bigDate.setFullYear(bigd[0],bigd[1],bigd[2]);
				smallDate.setFullYear(smalld[0],smalld[1],smalld[2]);
				var today = new Date();
				if (smallDate>=bigDate)
				{
				}else
				{
					alert("End date must be greater tha Start date");
					return false;
				}
				return true;
			}
			else
			{
			   return false;
			}
		}				
	
	}
	
	function isInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
    return true;
	}

	function stripCharsInBag(s, bag)
	{
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}

	function daysInFebruary (year)
	{
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	
	function DaysArray(n)
	{
		for (var i = 1; i <= n; i++)
		{
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
		}
   		return this
	}
	
	var dtCh= "-";
	
	function isDate(dtStr)
	{
		//alert(dtStr);
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strYear=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strDay=dtStr.substring(pos2+1)
		strYr=strYear
		//alert(strYear+'-'+strMonth+'-'+strDay);
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			alert("The date format should be : yyyy-mm-dd")
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			alert("Please enter a valid month")
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			alert("Please enter a valid day")
			return false
		}
		if (strYear.length != 4 || year==0 ){
			alert("Please enter a valid 4 digit year");
			return false
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			alert("Please enter a valid date")
			return false
		}
		return true
	}
	
	function checkme(id,no)
	{
		//alert("Befor: id=" + id + "-no=" + no);
	   if(no=='plus')
	   	id=parseInt(id)+1;
	   if(no=='minus')
	   	id=parseInt(id)-1;
	   
	   //alert("Befor: id=" + id + "-no=" + no);
	   
	   if(document.getElementById('photo_product_chk_'+id)!=null)
	   {
			if(document.getElementById('photo_product_chk_'+id).checked)
			{
				document.getElementById('photo_product_chk_'+id).checked=false;
			}
	   }
	}
	
    function uncheck_compete(id,no)
    {
        //alert("Befor: id=" + id + "-no=" + no);
        if(no == 'pro')
            id2 = parseInt(id)+1;
        if(no == 'personal')
            id2 = parseInt(id)-1;
       //alert("Befor: id=" + id + "-no=" + no);
        if(document.getElementById('photo_product_chk_'+id) != null && document.getElementById('photo_product_chk_'+id2) != null)
        {
            if(document.getElementById('photo_product_chk_'+id).checked == true)
                document.getElementById('photo_product_chk_'+id2).checked = false;
        }
    }

	function submitFedexRateForm(event)
	{
	    if (event.keyCode==13) 
		{
			getFedexRates('fedexTotal', SITE_URL+'shopping/fedexrate/', 'frmFedexRate');
			return false;
		}
		return false;
	}
	
	
	
	
    function getFlashMovie(movieName)
	{
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		return (isIE) ? window[movieName] : document[movieName];
	}
	function pauseVideo()
	{
		 var fplayer = getFlashMovie("flaMovie");
		 //alert(fplayer);
		 if (fplayer != 'undefined' && fplayer!= null )
		 {
			try
			{
				fplayer.pausePlayer();
			}
			catch (e)
			{
			}
			
		 }
	}
	function playVideo()
	{
		 //alert(fplayer);
		 var fplayer = getFlashMovie("flaMovie");
		 if (fplayer != 'undefined' && fplayer!= null )
		 {
		    try
			{
			   fplayer.playPlayer();
			}
			catch (e)
			{
			}
		 }
	}
	
      function call()
	  {
		 $('proText').innerHTML=$('professionalOptions').style.display=='none'?'Click on the &quot;+&quot; button to see Professional Options':'Click on the &quot;-&quot; button to close Professional Options';
	  }
	  
	function checkcomment1(id,edit)
	{   
	  
	  if(FCKeditorAPI.GetInstance('comment'+id).GetXHTML()=="")
	  {
	     alert("Please Enter Message");
	     return false;
	  }
	  else
	  {
	      if(edit==0)
	       url=SITE_URL+'forums/postcommentsave/0/'+id+'/null/'+base64_encode(FCKeditorAPI.GetInstance('comment'+id).GetXHTML());
	      else
	       url=SITE_URL+'forums/postcommentsave/0/'+id+'/'+edit+'/'+base64_encode(FCKeditorAPI.GetInstance('comment'+id).GetXHTML());
	      //alert(url);
	     
	     custome_updater('test_'+id, url)
	     
	      //new Ajax.Updater('test_'+id,url,{asynchronous:true, evalScripts:true, requestHeaders:['X-Update', 'test_'+id]});
	     //new Ajax.Updater('test_231',url, {asynchronous:true, evalScripts:true, parameters:Form.serialize(Event.element(event).form), requestHeaders:['X-Update', 'test_231']})
	     return false;
	  } 
	}
	
	function base64_encode (data) {
    // http://kevin.vanzonneveld.net
    // +   original by: Tyler Akins (http://rumkin.com)
    // +   improved by: Bayron Guevara
    // +   improved by: Thunder.m
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Pellentesque Malesuada
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: utf8_encode
    // *     example 1: base64_encode('Kevin van Zonneveld');
    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
 
    // mozilla has this native
    // - but breaks in 2.0.0.12!
    //if (typeof this.window['atob'] == 'function') {
    //    return atob(data);
    //}
        
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc="", tmp_arr = [];
 
    if (!data) {
        return data;
    }
 
    data = this.utf8_encode(data+'');
    
    do { // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);
 
        bits = o1<<16 | o2<<8 | o3;
 
        h1 = bits>>18 & 0x3f;
        h2 = bits>>12 & 0x3f;
        h3 = bits>>6 & 0x3f;
        h4 = bits & 0x3f;
 
        // use hexets to index into b64, and append result to encoded string
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);
    
    enc = tmp_arr.join('');
    
    switch (data.length % 3) {
        case 1:
            enc = enc.slice(0, -2) + '==';
        break;
        case 2:
            enc = enc.slice(0, -1) + '=';
        break;
    }
 
    return enc;
}
function utf8_encode ( argString ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
 
    var string = (argString+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0;
 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);
        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {
            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {
            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;
        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);
    }
 
    return utftext;
} 
   function catchevent(event,formname)
   {
  
	  if(event.keyCode==13)
	  {
	  
	        submitForm(formname);	
	      
	  }
   }


   function lightIE8(event,formname, action)
   {
	  //alert(detect)
	  place = detect.indexOf('msie')
	  //alert(place)
	  if(place>=0)
	  {
		 if(event.keyCode==13)
		 {
			new Ajax.Updater('login',SITE_URL+'user/'+action, {asynchronous:true, evalScripts:true, parameters:Form.serialize(Event.element(event).form), requestHeaders:['X-Update', 'login']});
		 }
	  }
   }
   
   
   /////// T H E S E   F U N C T I O N S  A R E  F O R  S H I P P I N G  S E R V I C E S \\\\\\\\\\
   function onmiceout(ths)
   {
	   if($(ths).title!='1'){
		   $(ths).className = 'miceOut';
	   }
	   return true;
   }
   function onmicemove(ths)
   {
	   var dmarr = $$('miceMove')
	   var cntr=0;
	   
	   for(i=0;i<dmarr.length;i++ )
	   {
		   if($(dmarr[i])!=ths && ($(ths).title!='1' || cntr>1)) {
			   $(dmarr[i]).className = 'miceOut';
			   
		   }else{cntr++;}
	   }
	   $(ths).className = 'miceMove';
	   return true;
   }
   function onmiceclick(ths)
   {
	   var dmarr = $$('div[title="1"]')
	   for(i=0;i<dmarr.length;i++ )
	   {
		   $(dmarr[i]).className = 'miceOut';
		   $(dmarr[i]).title='0';
	   }
	   $(ths).title='1';
	   $(ths).className = 'miceMove';
	   Element.hide('select_shipping_service')
	   $('ship_service_value').value= $(ths.id+"SrvcName").value + " - "+ $(ths.id+"Amt").value;
	   //alert($('shippingservice').value);
	   $('shippingservice').value=$(ths.id+"Srvc").value;
	   //alert($('shippingservice').value);
	   updateShoppingCartTotals();
	   return true;
   }
   /////// T H E S E   F U N C T I O N S  A R E  F O R  S H I P P I N G  S E R V I C E S \\\\\\\\\\


   function displaycap()
   {
	  if($('cp').style.display=='none')
		 $('cp').style.display='block';
   }
   function updtCC()
   {
	  var args="";
	  var f="updateCCInfo";
	  args+=$("UsercreditcardsId").value+"|";
	  args+=$("UsercreditcardsMonth").value+"|";
	  args+=$("UsercreditcardsYearYear").value+"|";
	  args+=$("ccNumberFromAuth").value+"|";
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  
	  var str=f+"__"+args;
	  url=SITE_URL+'shopping/wrapperF/'+str;
	  
	  custome_updater("ds", url);
   }
   
   function loadTeaser()
   {
	  var args="";
	  var f="loadTeaser";
	  args+="0|0|0|";
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  
	  var str=f+"__"+args;
	  url=SITE_URL+'index/wrapperF/'+str;
	  
	  custome_updater("homeTeaserWall", url);
	  
	  /*
	  var args="";
	  var f="loadDecade";
	  args+="0|0|0|";
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  
	  var str=f+"__"+args;
	  url=SITE_URL+'index/wrapperF/'+str;
	  
	  custome_updater("homeTeaserWall", url);
	  */
	  
   }
   
   function rggcb()
   {
	  var args="";
	  var f="rggcb";
	  var aowner="";
	  if($("Frecipient").checked)
	  {
		 aowner="recepient";
	  }
	  if($("Fthirdparty").checked)
	  {
		 aowner="thirdparty";
	  }
	  
	  args+=$("fedexAcNumber").value+"|";
	  args+=aowner+"|";
	  
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  if(aowner !="" && $("fedexAcNumber").value!='')
	  {
		 var str=f+"__"+args;
	  	 url=SITE_URL+'shopping/wrapperF/'+str;
		 custome_updater("CheckOut1GoogleCheckoutButton", url);
	  }
   }
   function rggc()
   {
	  var args="";
	  var f="cctypeinch1";
	  var aowner="";
	  
	  args+=$("UsercreditcardsCcType").value+"|";
	  args+=aowner+"|";
	  
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  
	  var str=f+"__"+args;
	  url=SITE_URL+'shopping/wrapperF/'+str;
	  custome_requester(url);
	  
   }
   function checkTemp1()
   {
	  loc = $('location').value;
	  if(loc.indexOf('"')>=0)
	  {
		 $('temp').value = 1;
	  }else{
		 $('temp').value = 0;
	  }
   }
   function stpxession(sessionvar, sessionval)
   {
	setunsetphpsession(sessionvar, sessionval);
   }
   function setunsetphpsession(sessionvar, sessionval)
   {
		 var args = "";
		 var f = "setunsetsession";
		 args+=sessionvar+"|";
		 args+=sessionval+"|";
		 
		 args=Base64.encode(args);
		 f=Base64.encode(f);
		 
		 var str=f+"__"+args;
		 url = SITE_URL+'shopping/wrapperF/'+str;
		 //alert(url);
		 //var url=SITE_URL+'user/setunsetphpsession/?sessionvar='+sessionvar+"&sessionval="+sessionval;
		 url=SITE_URL+'shopping/wrapperF/'+str;
		 new Ajax.Updater(
							    "",
							    url, 
							    {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', ""]}
				         );	
   }
   function _body_onload()
   {
	   setScrollInIE();
	   turnAutocompleteOff();
	   loff();
	   var std_context = 'login_up';
	   SetHelpPrefix(''); SetContext(std_context, '');
	   
	   //setFocus();
	   try {
		   if (top && top.leftFrame) {
			   SetExpandLeftFrame();
		   }
	   } catch (e) { }
   }
   
   function _body_resize()
   {
	   setScrollInIE();
	   lresize();
   }
   
   function _body_onunload()
   {
	   
	   lon();
	   
   }
   
   function preloader()
   {
	  str='<table border="0" cellspacing="0" cellpadding="0" id="loaderContainer" onClick="return false;"><tr><td id="loaderContainerWH"><div id="loader" style="z-index: 10;"><table border="0" cellpadding="0" cellspacing "0" width="100%"><tr><td><p><img alt="loading..." title="" width="126" height="22" src="'+SITE_URL+'img/loading10.gif"><strong>Please wait Loading...</strong></p></td></tr></table></div><script>_lon();</script></td></tr></table>';
	  return str;
   }
   
   function updateuspsfree()
   {
	  $('uspsfree').innerHTML="test";
	  
   }
   
   var opt_no_frames = false;
   var opt_integrated_mode = false;
   var videoplay=false;
   
   function hello(val)
   {
		   videoplay=val;
   }
	   
	
   function setText(ctrl, str)
   {
		if((typeof( ctrl ) == "string" ) )
		{
			var obj = $(ctrl);
		}
		else
		{
			var obj = ctrl;	
		}
		if (obj.value == str)
		{
			obj.value = "";
		}
   }
	function removeText(ctrl, str)
	{
		if((typeof( ctrl ) == "string" ) )
		{
			var obj = $(ctrl);
		}
		else
		{
			var obj = ctrl;	
		}
		if (obj.value == "")
		{
			obj.value = str;
		}
	}
	function submitForm1(frm)
	{
		//var frm;
		if((typeof( frm ) == "string" ) )
		{
			frm = $(frm);
		}
		else
		{
			frm = frm;	
		}
		frm.submit();
	}
	
	function loadAmazonCloud()
	{
	  var args="";
	  var f="loadAmazonCloud";
	  args+="0|0|0|";
	  args=Base64.encode(args);
	  f=Base64.encode(f);
	  
	  var str=f+"__"+args;
	  url=SITE_URL+'products/wrapperF/'+str;
	  
	  custome_updater("amazon", url);
	}
	
	function OnUrlChange2(elmnt)
	{
	  var oRegex = new Object() ;
	  oRegex.UriProtocol = /^(((http|https|ftp|news):\/\/)|mailto:)/gi ;
	  oRegex.UrlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi ;
	  oRegex.UrlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi ;
	  oRegex.ReserveTarget = /^_(blank|self|top|parent)$/i ;
	  oRegex.PopupUri = /^javascript:void\(\s*window.open\(\s*'([^']+)'\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*\)\s*$/ ;
	  // Accessible popups
	  oRegex.OnClickPopup = /^\s*on[cC]lick="\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*"$/ ;
	  oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ;
	  
	  var sUrl = $(elmnt).value ;
	  var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
	  if ( sProtocol )
	  {
		sUrl = sUrl.substr( sProtocol[0].length ) ;
		$(elmnt).value = sUrl ;
	  }
	}
	function submitCCListForm(vl)
	{
		if(vl.value == -11 )
		{
			window.location.href = SITE_URL + "user/add_cc";
		}
		else if(vl.value == 0 )
		{
			window.location.href = SITE_URL + "user/ccinfo";
		}
		else
		{
			window.location.href = SITE_URL + "user/edit_cc/" + vl.value;
		}
	};
	
//-->
