var currentcurr=1;

function currentcurrency(currency)
{
		currentcurr = currency;
		return currentcurr;
}


function getxmlhttpobject()
{
	var xmlhttp=null;
	try
	{
		//Firefox, Opera 8.0+, Safari
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)
	{
		//Internet Explorer
		try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); //Internet Explorer 6.0+
		}
		catch(e)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer 5.5+
		}
	}
	return xmlhttp;
}
 
 var currenctamt=1;
//change Currency on select country
function changeAmount(val,amt)
 {
 	var contid = val;
	if(contid==1)
		var cursymb = '$';
	if(contid==2)
		var cursymb = '&euro;';
	if(contid==3)
		var cursymb = '&pound;';
	if(contid==4)
		var cursymb = '&yen;';
	if(contid==5)
		var cursymb = '$';
		
	for(var i=0;i<5;i++)
			{
				if(document.ordform1.curr_code[i].value==contid)
				{
					document.ordform1.curr_code[i].checked = true;
					break;
				}
				
	}	
		
	document.getElementById('cont').disabled= true;
	document.getElementById('lbl3').innerHTML= cursymb;
	document.getElementById('lbl4').innerHTML= cursymb;
	document.getElementById('lbl5').innerHTML= cursymb;
	document.getElementById('lbl6').innerHTML= cursymb;
	
	var priceval = amt;
	
	
	if(val!=1){
		//alert(contid);
		
		var myurl="change.php?cont="+contid+"&amt="+priceval;
		xmlhttp=getxmlhttpobject();
		
		if(xmlhttp==null)
			{
				alert("Your browser does not support AJAX!");
				return;
			}
		xmlhttp.open("GET",myurl,true);
		xmlhttp.send(null);
		
		if(val != -1)
			{
				
				xmlhttp.onreadystatechange=function(val,amt){
					if (xmlhttp.readyState==4)
					{	
						if(xmlhttp.responseText)
						{	
							currenctamt=xmlhttp.responseText;
														
							document.getElementById('cont').disabled= false;
							if(document.ordform1.fprice_indollar.value!=''){
								changeprice();
							}
							if(document.ordform1.sizeprice_indollar.value!=''){
								changeprice1();
							}
						}
						else
						{
							alert("Ajax not Working");
						
						}
			
					}
					
				}
				
			}
	}else{
		currenctamt=1;
			document.getElementById('cont').disabled= false;
						
			if(document.ordform1.hidprice.value!=''){
				changeprice();
			}
			if(document.ordform1.sizeprice.value!=''){
				changeprice1();
			}
	}
 	
	
 
 }
 
  
 function showPricenew(val,amt) 
{
	//alert('val'+val);
	///alert(amt);
	if(val==1){
			currenctamt=1;
			document.getElementById('cont').disabled= false;
			if(document.ordform1.hidprice.value!=''){
				changeprice();
			}
			if(document.ordform1.sizeprice.value!=''){
				changeprice1();
			}
	}else{
		if (xmlhttp.readyState==4)
		{	
			if(xmlhttp.responseText)
			{	
				//alert('converter '+xmlhttp.responseText);
				currenctamt=xmlhttp.responseText;
				document.getElementById('cont').disabled= false;
				if(document.ordform1.fprice_indollar.value!=''){
					//alert('hidprice '+document.ordform1.fprice_indollar.value);
					changeprice();
				}
				if(document.ordform1.sizeprice_indollar.value!=''){
					//alert('sizeprice '+document.ordform1.sizeprice_indollar.value);
					changeprice1();
				}
			}
			else
			{
				alert("Ajax not Working");
			
			}
			
		}
	}
}



function showcurrencyamt(){
	//alert('currenctamt'+currenctamt);
	//alert(val);
	var val=document.ordform1.size.value;
	var type=document.ordform1.imgtype.value;
	if(type==''){
		type=1;
	}
	//alert(type);
	var myurl="getframeprice.php?type="+type+"&sizeval="+val;
		//var securl = "getdata.php?frame="+val;
		
		xmlhttp=getxmlhttpobject();
		//xttp=getxmlhttpobject();
		
		if(xmlhttp==null)
			{
				alert("Your browser does not support AJAX!");
				return;
			}
		xmlhttp.open("GET",myurl,true);
		//xttp.open("GET",securl,true);
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=show_frameprice;
		
	
}
function show_frameprice(){
	var currselected=1;
	if((document.getElementById('curr_code1').checked)==true)
	{
			currselected=1;
	}
	if((document.getElementById('curr_code2').checked)==true)
	{
			currselected=2;
	}
	if((document.getElementById('curr_code3').checked)==true)
	{
			currselected=3;
	}
	if((document.getElementById('curr_code5').checked)==true)
	{
			currselected=5;
	}
	
	
	
	if (xmlhttp.readyState==4)
	{	
		if(xmlhttp.responseText)
		{
			//document.getElementById('priceid').innerHTML= xmlhttp.responseText;
			var val=xmlhttp.responseText;
			//alert(val);
			document.ordform1.fprice_indollar.value=val;			
			
			//Comment 1
			if((document.getElementById('curr_code1').checked)==true)
			{
			document.getElementById('priceid11').innerHTML=val;
			
			}
			else
			{
						
					var myurl="change.php?cont="+currselected+"&amt="+val;
					
					xmlhttp=getxmlhttpobject();
					
					if(xmlhttp==null)
						{
							alert("Your browser does not support AJAX!");
							return;
						}
					xmlhttp.open("GET",myurl,true);
					xmlhttp.send(null);
					
					if(currentcurr != -1)
						{
							xmlhttp.onreadystatechange=function(currselected,val){
								if (xmlhttp.readyState==4)
								{	
									if(xmlhttp.responseText)
									{	
										newamt=xmlhttp.responseText;
										document.getElementById('priceid11').innerHTML=newamt;
										
									}
									else
									{
										alert("Ajax not Working");
									
									}
						
								}
								
							}
							
						}
						}
			
			//alert(val);
			
			
			document.ordform1.hidprice.value=val;
			var sizeprice=document.ordform1.sizeprice.value;
			//alert(sizeprice);
			var actualamt=currenctamt*sizeprice;
			
			if((document.getElementById('curr_code1').checked)==true)
			{
			var actualamt=currenctamt*sizeprice;
			}
			else
			{
			var actualamt=currenctamt;	
			}
			
			
			
			//alert(actualamt);
			actualamt= Math.round(actualamt*Math.pow(10,2))/Math.pow(10,2);
			document.getElementById('priceid1').innerHTML= actualamt;
			document.getElementById('sizeof1').innerHTML= document.ordform1.size.value;
			document.getElementById('subject1').innerHTML= document.ordform1.subjectof.value;
			var fprice =document.getElementById('priceid11').innerHTML;
			fprice= Math.round(fprice*Math.pow(10,2))/Math.pow(10,2);
			document.ordform1.hidprice.value=fprice;
			//alert(fprice);
			var sprice =document.getElementById('priceid1').innerHTML;
			var total=parseFloat(fprice)+parseFloat(sprice);
			var deposit=parseFloat(total)*parseFloat(0.25);
			total= Math.round(total*Math.pow(10,2))/Math.pow(10,2);
			deposit= Math.round(deposit*Math.pow(10,2))/Math.pow(10,2);
			document.getElementById('ptotal').innerHTML=total;
			document.getElementById('pdeposit').innerHTML= Math.round(deposit);
			document.ordform1.subjectof.value=document.getElementById('subject1').innerHTML;
			document.ordform1.size.value=document.getElementById('sizeof1').innerHTML;
			document.ordform1.price.value=total;
			document.getElementById('cont').disabled= false;
		}else{
				alert('Ajax not Working');	
			}
		
	}
}
function getcurrencyamt1(val){
	
	var size=document.ordform1.size.value;
	//alert('size'+size);
				//alert('val'+val);
	var myurl="getframeprice.php?type="+val+"&sizeval="+size;
		//var securl = "getdata.php?frame="+val;
		
		xmlhttp=getxmlhttpobject();
		//xttp=getxmlhttpobject();
		
		if(xmlhttp==null)
			{
				alert("Your browser does not support AJAX!");
				return;
			}
		xmlhttp.open("GET",myurl,true);
		//xttp.open("GET",securl,true);
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=showcurrencyamt1;
	
}
function showcurrencyamt1(){
	if (xmlhttp.readyState==4)
		{	
			if(xmlhttp.responseText)
			{		
				var val=xmlhttp.responseText;
				
				//var actualamt1=currenctamt*val;
				
				if(document.getElementById('curr_code1').checked==true)
				{
				
				var actualamt1=currenctamt*val;
				}
				else
				{
				var actualamt1=currenctamt;	
				}
				
				//alert('currenctamt'+currenctamt);
				//alert('val'+val);
				//alert(actualamt1);
				actualamt1= Math.round(actualamt1*Math.pow(10,2))/Math.pow(10,2);
				//comment 2
				document.getElementById('priceid11').innerHTML=actualamt1;
				
				var fprice =document.getElementById('priceid11').innerHTML;
				fprice= Math.round(fprice*Math.pow(10,2))/Math.pow(10,2);
				document.ordform1.hidprice.value=fprice;
						var sprice =document.getElementById('priceid1').innerHTML;
						var total=parseFloat(fprice)+parseFloat(sprice);
						var deposit=parseFloat(total)*parseFloat(0.25);
						total= Math.round(total*Math.pow(10,2))/Math.pow(10,2);
						deposit= Math.round(deposit*Math.pow(10,2))/Math.pow(10,2);
						document.getElementById('ptotal').innerHTML=total ;
						document.getElementById('pdeposit').innerHTML= Math.round(deposit);
						document.ordform1.subjectof.value=document.getElementById('subject1').innerHTML;
						document.ordform1.size.value=document.getElementById('sizeof1').innerHTML;
						document.ordform1.price.value=total;
						document.getElementById('cont').disabled= false;
						
			}else{
				alert('Select Size First');	
			}
		}
}
function showcurrencyamt2(val){
	//alert(currenctamt);
	//alert(val);
	var actualamt1=currenctamt*val;
	//alert(actualamt1);
	actualamt1= Math.round(actualamt1*Math.pow(10,2))/Math.pow(10,2);
	//comment 3
	document.getElementById('priceid11').innerHTML=actualamt1;

	document.ordform1.hidprice.value=actualamt1;
	
}
function changeprice(){
	//alert('changeprice '+document.ordform1.fprice_indollar.value);
	var cs;
	var actualamt1=currenctamt*document.ordform1.fprice_indollar.value;
	actualamt1=Math.round(actualamt1*Math.pow(10,2))/Math.pow(10,2);
	//comment 4
	
	//if((document.getElementById('curr_code1').checked)!=true)
	//{
		if (xmlhttp.readyState==4)
	{	
		if(xmlhttp.responseText)
		{
			//document.getElementById('priceid').innerHTML= xmlhttp.responseText;
			var val=xmlhttp.responseText;
			//alert(val);			
			
			//Comment 1
			if((document.getElementById('curr_code1').checked)==true)
			{
				cs=1;			
			}
			if((document.getElementById('curr_code2').checked)==true)
			{
				cs=2;			
			}
			if((document.getElementById('curr_code3').checked)==true)
			{
				cs=3;			
			}
			if((document.getElementById('curr_code5').checked)==true)
			{
				cs=5;			
			}
			
					var valtosend = document.getElementById('priceid11').innerHTML.toString();	
					var myurl="change.php?cont="+cs+"&amt="+valtosend;
					
					xmlhttp=getxmlhttpobject();
					
					if(xmlhttp==null)
						{
							alert("Your browser does not support AJAX!");
							return;
						}
					xmlhttp.open("GET",myurl,true);
					xmlhttp.send(null);
					
					if(currentcurr != -1)
						{
							xmlhttp.onreadystatechange=function(cs,actualamt1){
								if (xmlhttp.readyState==4)
								{	
									if(xmlhttp.responseText)
									{	
										namt=xmlhttp.responseText;
										document.getElementById('priceid11').innerHTML=namt;
										
									}
									else
									{
										alert("Ajax not Working");
									
									}
						
								}
								
							}
							
						}
						
			
		}else{
				alert('Ajax not Working');	
			}
		
	}
			//document.getElementById('priceid11').innerHTML=actualamt1;
	//}
	
	
	document.ordform1.hidprice.value=actualamt1;
	//alert(document.ordform1.hidprice.value);
}
function changeprice1(){
	//alert('changeprice1 '+document.ordform1.sizeprice_indollar.value);
	var actualamt1=currenctamt*document.ordform1.sizeprice_indollar.value;
	actualamt1=Math.round(actualamt1*Math.pow(10,2))/Math.pow(10,2);
	document.getElementById('priceid1').innerHTML=actualamt1;
	document.ordform1.sizeprice.value=actualamt1;
	
			var total=parseFloat(document.ordform1.sizeprice.value)+parseFloat(document.ordform1.hidprice.value);
			var deposit=parseFloat(total)*parseFloat(0.25);
			total= Math.round(total*Math.pow(10,2))/Math.pow(10,2);
			deposit= Math.round(deposit*Math.pow(10,2))/Math.pow(10,2);
			document.getElementById('ptotal').innerHTML=total;
			document.getElementById('pdeposit').innerHTML= Math.round(deposit);
			document.ordform1.price.value=total;
}






function ajaxframeprice(divname,imgname){
	var size=document.ordform1.size.value;
	if(size==''){
		size='12x16';
	}//alert(size);	
	var myurl="getframeprice.php?type="+imgname+"&sizeval="+size;
		//document.ordform1.imgtype.value=imgname;
		xmlhttp=getxmlhttpobject();
		
		if(xmlhttp==null)
			{
				alert("Your browser does not support AJAX!");
				return;
			}
		xmlhttp.open("GET",myurl,true);
		xmlhttp.send(null);
		if(divname != '')
			{
				 xmlhttp.onreadystatechange=function(){
				if (xmlhttp.readyState==4)
				{
					if(xmlhttp.responseText!='')
					{	//alert('fdf'+xmlhttp.responseText);	
						var val=xmlhttp.responseText;
						//document.ordform1.feffect.value=val;
						
						setStyle_mouseover(divname,val);
						
						
					}else{
						alert('Ajax not Working');	
					}
				}}
				
			}
}
function ajaxframeeffect(divname){
	//alert('1');
	if (xmlhttp.readyState==4)
		{
			if(xmlhttp.responseText!='')
			{	alert('1');	
				var val=xmlhttp.responseText;
				document.ordform1.feffect.value=val;
			}else{
				alert('me');	
			}
		}
}