function recomendar(id){
ancho=440; alto=400;
var _W=window.open('send-to-friend.php?id='+id,'recomendar',"scrollbars=yes,width="+ancho+",height="+alto); 
_W.focus();
iz=(screen.width-ancho) / 2;
de=(screen.height-alto) / 2;
_W.moveTo(iz,de);
}
function openPopup(id){
ancho=800; alto=600;
var _W=window.open(id,'recomendar',"scrollbars=yes,width="+ancho+",height="+alto);
_W.focus();
iz=(screen.width-ancho) / 2;
de=(screen.height-alto) / 2;
_W.moveTo(iz,de);
}
var preciototal="";
function openChat()
{
ancho=200; alto=320;
var _W=window.open('chat.html','Chat',"scrollbars=yes,width="+ancho+",height="+alto);
_W.focus();
iz=(screen.width-ancho) / 2;
de=(screen.height-alto) / 2;
_W.moveTo(iz,de);
}
function imprimir(id)
{
ancho=570; alto=550;
var _W=window.open('verimprimir.php?id='+id,'imprimir',"scrollbars=yes,width="+ancho+",height="+alto);
_W.focus();
iz=(screen.width-ancho) / 2;
de=(screen.height-alto) / 2;
_W.moveTo(iz,de);
}
function openWindow(id)
{
ancho=720; alto=550;
var _W=window.open('intership'+id+'.php','InterShip',"scrollbars=yes,width="+ancho+",height="+alto);
_W.focus();
iz=(screen.width-ancho) / 2;
de=(screen.height-alto) / 2;
_W.moveTo(iz,de);
}
function showDetails(){

    $('#cotizacion').css('display','block');	
}
function calculateFee()
{
	parent.dhxLayout.progressOn();
    
     parent.layout.progressOn();  
    
	//document.getElementById('cotizacion').style.display = 'none';
	var study = document.getElementById('study');
 
	var withMaterials = document.getElementById('materials');
      
	if(withMaterials) {
		withMaterials = withMaterials.checked;
		if(withMaterials) {
			withMaterials = "1"
		}
		else {
			withMaterials = "0"
		}
	}
	else {
		withMaterials = "0";
	}
	
	var type = document.getElementById('stay');
	var weeks = document.getElementById('weeks');
	var horasprivate = document.getElementById('horasprivate');
	var tours = 0 //document.getElementById('tours');
	
	var transferencia = getRadioButtonSelectedValue(document.schedule.transferair);

    if((study.value > 0) && (type.value > 0) && (weeks.value > 0))
	{
	       
                  
		$.ajax({
		        url:'calculateFee.php',
				data:'study='+study.value+'&materials='+withMaterials+'&type='+type.value+'&weeks='+weeks.value+'&tours='+tours+'&transferencia='+transferencia+'&horasprivate='+horasprivate.value,
				type:'post',
				success:function(fee){
			         		
                               parent.dhxLayout.progressOff();
                               parent.layout.progressOff();  
                    json=eval("("+fee+")");
                    var frame="";
                    var radio2="";
                   
                         
                         for(i=0;i<window.parent.frames.length;i++){
                              if(typeof(window.parent.frames[i].metod)!="undefined"){
                                    
                                    frame=window.parent.frames[i].document.getElementById('totalcost');
                                    radio2=window.parent.frames[i].document.getElementById('radio2');
                                     amount=window.parent.frames[i].document.getElementById('amount');
                                     products=window.parent.frames[i].document.getElementById("products");
                                     totals=window.parent.frames[i].document.getElementById('total');
                              }
                            
                         }
                    
					//$('#cotizacion').css('display','block');
                    parent.price=json.totalprice;
                   
					$('#cotizacion').html(json.details);
					$(totals).html("Grand Total: "+"$ "+json.totalprice+" US");
                    
                    $('#price').html("$ "+json.totalprice+" US");
                    $(products).html(json.details);
                     
                    //parent.price=json.totalprice;
    	            document.getElementById('gran_total').value=json.totalprice;
                    var total=document.getElementById('gran_total');
                    frame.innerHTML="$ "+total.value+" (US)";
                    radio2.value=total.value;
                    amount.value=total.value;
					//$('#calculating').css('display','none');
				}	
		});
		/*feeCalculator(study.value, withMaterials, type.value,weeks.value,tours.value,transferencia);*/
	} 
	else 
	{
		if(!transferencia)
		{
			alert("Please select your airport transfer.");
		}
		else
		{
			if(study.value < 1)
			{
				alert("Please select your study schedule.");
				study.className = 'rojo';
				study.disabled = false;
				study.focus();
			}
			else if(type.value < 1)
			{
				alert("Please select your Accommodation Type.");
				type.className = 'rojo';
				type.disabled = false;
				type.focus();
		
			}
			else if(weeks.value < 1)
			{	
				alert("Please select the number of weeks");
				weeks.className = 'rojo';
				weeks.disabled = false;
				weeks.focus();
			}
		}
		
		study.disabled = false;
		weeks.disabled = false;
		type.disabled = false;
		
	}
	
	
}
function calculate_fee()
{

    
     parent.layout.progressOn();  
    
	//document.getElementById('cotizacion').style.display = 'none';
	var study = document.getElementById('study1');
  
	var withMaterials = document.getElementById('materials1');
      
	if(withMaterials) {
		withMaterials = withMaterials.checked;
		if(withMaterials) {
			withMaterials = "1"
		}
		else {
			withMaterials = "0"
		}
	}
	else {
		withMaterials = "0";
	}
	
	var type = document.getElementById('stay1');
	var weeks = document.getElementById('weeks1');
	var tours = 0 //document.getElementById('tours');
	var horasprivate = document.getElementById('horasprivate1');

	var transferencia = getRadioButtonSelectedValue(document.schedule.transferair);
     
    if((study.value > 0) && (type.value > 0) && (weeks.value > 0))
	{             
		$.ajax({
		        url:'calculateFee.php',
				data:'study='+study.value+'&materials='+withMaterials+'&type='+type.value+'&weeks='+weeks.value+'&tours='+tours+'&transferencia='+transferencia+'&horasprivate='+horasprivate.value,
				type:'post',
				success:function(fee){
			         		
                               parent.dhxLayout.progressOff();
                               parent.layout.progressOff();  
                    json=eval("("+fee+")");
                    var frame="";
                    var radio2="";
                    var totals="";
                    var products="";
                    var amount="";
                    //if(navigator.appName.indexOf("Microsoft Internet Explorer")==-1){
//                           
//                        frame=window.parent.frames[9].document.getElementById('totalcost1')
//                        
//                        radio2=window.parent.frames[10].document.getElementById('radio2_1');
//                        alert(document.getElementById('radio2_1'));
//                        alert(radio2); 
//                        amount=window.parent.frames[10].document.getElementById('amount_1');
//                    }
//                    else
//                    {
                         
                         for(i=0;i<window.parent.frames.length;i++){
                              if(typeof(window.parent.frames[i].metod1)!="undefined"){
                                    
                                    frame=window.parent.frames[i].document.getElementById('totalcost1');
                                    radio2=window.parent.frames[i].document.getElementById('radio2_1');
                                     amount=window.parent.frames[i].document.getElementById('amount1');
                                     products=window.parent.frames[i].document.getElementById("products");
                                     totals=window.parent.frames[i].document.getElementById('total');
                                     
                              }
                            
                         }
                    //}
					//$('#cotizacion').css('display','block');
                    parent.price=json.totalprice;
                   	$(totals).html("Grand Total: "+"$ "+json.totalprice+" US");
                     $(products).html(json.details);
					$('#cotizacion').html(json.details);
					$('#price1').html("$ "+json.totalprice);
                    
                     
                    //parent.price=json.totalprice;
    	            document.getElementById('gran_total1').value=json.totalprice;
                    var total=document.getElementById('gran_total1');
                    frame.innerHTML="$ "+total.value+" (US)";
                    radio2.value=total.value;
                    amount.value=total.value;
					//$('#calculating').css('display','none');
				}	
		});
		/*feeCalculator(study.value, withMaterials, type.value,weeks.value,tours.value,transferencia);*/
	} 
	else 
	{
		if(!transferencia)
		{
			alert("Please select your airport transfer.");
		}
		else
		{
			if(study.value < 1)
			{
				alert("Please select your study schedule.");
				study.className = 'rojo';
				study.disabled = false;
				study.focus();
			}
			else if(type.value < 1)
			{
				alert("Please select your Accommodation Type.");
				type.className = 'rojo';
				type.disabled = false;
				type.focus();
		
			}
			else if(weeks.value < 1)
			{	
				alert("Please select the number of weeks");
				weeks.className = 'rojo';
				weeks.disabled = false;
				weeks.focus();
			}
		}
		
		study.disabled = false;
		weeks.disabled = false;
		type.disabled = false;
		
	}
	
	
}
function dblurea(x)
{
	x.className = '';
}

/*function get_discount(){
        
        code=document.getElementById('promotionalCode').value;
        if(!/^\s+$/.test(code))
        {            if (window.XMLHttpRequest)
                   {// code for IE7+, Firefox, Chrome, Opera, Safari
                          xmlhttp=new XMLHttpRequest();
                   }
                   else
                  {// code for IE6, IE5
                     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                    xmlhttp.onreadystatechange=function()
                  {
                
                  if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                    var total=0;
                    respuesta=xmlhttp.responseText;
                      objeto_json=eval("("+respuesta+")")
                      if(objeto_json.result>0)
                       { 
                       document.getElementById('cost_discount').style.display="block"
                        document.getElementById('value_discount').style.display="block";
                        discount=objeto_json.discount.split('.');
                        document.getElementById('value_discount').innerHTML="You have discount of: "+parseInt(discount[1])+"%";
                        desc=objeto_json.discount;
                        
                        total_cost="";
                       
                        if(navigator.appName.indexOf("Microsoft Internet Explorer")==-1){
                            total_cost=window.parent.frames[10].document.getElementById('totalcost');
                            amount=window.parent.frames[10].document.getElementById('amount');
                            radio2=window.parent.frames[10].document.getElementById('radio2');
                        }
                        else
                        {
                              for(k=0;k<window.parent.frames.length;k++){
                                      if(typeof(window.parent.frames[k].metod)!="undefined"){
                                              total_cost=window.parent.frames[k].document.getElementById('totalcost');
                                              amount=window.parent.frames[k].document.getElementById('amount'); 
                                                radio2=window.parent.frames[k].document.getElementById('radio2');
                                      }
                                   
                              }
                        }
                     
                       
                        costototal=total_cost.innerHTML.split('$');   
                        
                        if(costototal[1].indexOf(','))
                        {
                              costototal[1]=costototal[1].replace(',','');
                               
                        } 
                        costototal=parseFloat(costototal[1]);
                        
                        costo_discount=(parseFloat(desc))*costototal;
                        costo_discount=costototal-costo_discount;
                        costo_discount=costo_discount.toFixed(2);       
                        cost=costo_discount.split('.');
                        if(cost[0].length>=4 && cost[0].length<=5){
                              var num=cost[0].replace(/\./g,"")
                              if(!isNaN(num)){
                              num = num.toString().split("").reverse().join("").replace(/(?=\d*\.?)(\d{3})/g,"$1,");
                              num = num.split("").reverse().join("").replace(/^[\.]/,"");  
                              costo_discount=num+"."+cost[1];
                                   }
                        }
                        total_cost.innerHTML="$ "+costo_discount +"(US)";
                                                
                        radio2.value=costo_discount;
                        amount.value=costo_discount;
                        document.getElementById('cost_discount').innerHTML="Price with discount $ "+costo_discount;
                        document.getElementById('vdiscount').value=objeto_json.discount;
                        document.getElementById('cdiscount').value=costo_discount; 
                       }
                       else
                       {
                          alert('Por favor escriba o copie y pegue el codigo proporcionado');
                          document.getElementById('promotionalCode').value=""
                           document.getElementById('value_discount').innerHTML="";
                          document.getElementById('cost_discount').innerHTML="";
                          document.getElementById('value_discount').style.display="none";
                          document.getElementById('costo_discount').style.display="none";
                       }
                          
                          
                         
                          
                        
                         
                    }
                   
                  }
                   
                  xmlhttp.open("GET","http://spanishschoolecora.com/pruebas/get_code.php?code="+document.getElementById('promotionalCode').value,true);
                xmlhttp.send(); 
        }
        else
        {
             alert('Por favor ingrese un codigo')
        }  
 }
*/
function get_discount(){
    code=document.getElementById('promotionalCode').value;
    
   if(!/^\s+$/.test(code))
        { 
               $.ajax({
                     type:'post',
                     url:'get_code.php',
                     data:'code='+document.getElementById('promotionalCode').value,
                     success:function(desc){
                              objeto_json=eval("("+desc+")")
                      if(objeto_json.result>0)
                       { 
                       
                        document.getElementById('cost_discount').style.display="block"
                        document.getElementById('value_discount').style.display="block";
                        discount=objeto_json.discount.split('.');
                        document.getElementById('value_discount').innerHTML="You have discount of: "+parseInt(discount[1])+"%";
                        desc=objeto_json.discount;
                        
                        total_cost="";
                        var amount="";
                        
                              for(k=0;k<window.parent.frames.length;k++){
                                      if(typeof(window.parent.frames[k].metod)!="undefined"){
                                      
                                              total_cost=window.parent.frames[k].document.getElementById('totalcost');
                                            
                                              amount=window.parent.frames[k].document.getElementById('amount'); 
                                              radio2=window.parent.frames[k].document.getElementById('radio2');
                                              per_discount=window.parent.frames[k].document.getElementById('desc');
                                              price_discount=window.parent.frames[k].document.getElementById('desc_price');
                                      }
                                   
                              }
                        
                        $(per_discount).html("Percentage Discount: "+parseInt(discount[1])+"%");
                        
                        costototal=total_cost.innerHTML.split('$');   
                        
                        if(costototal[1].indexOf(','))
                        {
                              costototal[1]=costototal[1].replace(',','');
                               
                        } 
                        costototal=parseFloat(costototal[1]);
                        
                        costo_discount=(parseFloat(desc))*costototal;
                        costo_discount=costototal-costo_discount;
                        costo_discount=costo_discount.toFixed(2);       
                        cost=costo_discount.split('.');
                        if(cost[0].length>=4 && cost[0].length<=5){
                              var num=cost[0].replace(/\./g,"")
                              if(!isNaN(num)){
                              num = num.toString().split("").reverse().join("").replace(/(?=\d*\.?)(\d{3})/g,"$1,");
                              num = num.split("").reverse().join("").replace(/^[\.]/,"");  
                              costo_discount=num+"."+cost[1];
                                   }
                        }
                        total_cost.innerHTML="$ "+costo_discount +"(US)";
                        $(price_discount).html("Price with discount: "+total_cost.innerHTML);                        
                        radio2.value=costo_discount;
                        amount.value=costo_discount;
                        
                        document.getElementById('cost_discount').innerHTML="Price with discount $ "+costo_discount;
                        document.getElementById('vdiscount').value=objeto_json.discount;
                        document.getElementById('cdiscount').value=costo_discount; 
                       }
                       else
                       {
                          alert('Por favor escriba o copie y pegue el codigo proporcionado');
                          document.getElementById('promotionalCode').value=""
                           document.getElementById('value_discount').innerHTML="";
                          document.getElementById('cost_discount').innerHTML="";
                          document.getElementById('value_discount').style.display="none";
                          document.getElementById('cost_discount').style.display="none";
                       }
                          


                    }//fin de respuesta
 
              })
               

        }

}
function get_discount1(){
    code=document.getElementById('promotionalCode1').value;
    
   if(!/^\s+$/.test(code))
        { 
               $.ajax({
                     type:'post',
                     url:'get_code.php',
                     data:'code='+document.getElementById('promotionalCode1').value,
                     success:function(desc){
                              objeto_json=eval("("+desc+")")
                      if(objeto_json.result>0)
                       { 
                       
                        document.getElementById('cost_discount1').style.display="block"
                        document.getElementById('value_discount1').style.display="block";
                        discount=objeto_json.discount.split('.');
                        document.getElementById('value_discount1').innerHTML="You have discount of: "+parseInt(discount[1])+"%";
                        desc=objeto_json.discount;
                        
                        total_cost="";
                        var amount="";
                       // if(navigator.appName.indexOf("Microsoft Internet Explorer")==-1){
//                            total_cost=window.parent.frames[10].document.getElementById('totalcost');
//                            amount=window.parent.frames[10].document.getElementById('amount');
//                            radio2=window.parent.frames[10].document.getElementById('radio2');
//                        }
//                        else
//                        {
                              for(k=0;k<window.parent.frames.length;k++){
                                      if(typeof(window.parent.frames[k].metod1)!="undefined"){
                                      
                                              total_cost=window.parent.frames[k].document.getElementById('totalcost1');
                                              amount=window.parent.frames[k].document.getElementById('amount1'); 
                                                radio2=window.parent.frames[k].document.getElementById('radio2_1');
                                                 per_discount=window.parent.frames[k].document.getElementById('desc');
                                              price_discount=window.parent.frames[k].document.getElementById('desc_price');
                                      
                                      }
                                   
                              }
                        //}
                           $(per_discount).html("Percentage Discount: "+parseInt(discount[1])+"%");
                       
                        costototal=total_cost.innerHTML.split('$');   
                        
                        if(costototal[1].indexOf(','))
                        {
                              costototal[1]=costototal[1].replace(',','');
                               
                        } 
                        costototal=parseFloat(costototal[1]);
                        
                        costo_discount=(parseFloat(desc))*costototal;
                        costo_discount=costototal-costo_discount;
                        costo_discount=costo_discount.toFixed(2);       
                        cost=costo_discount.split('.');
                        if(cost[0].length>=4 && cost[0].length<=5){
                              var num=cost[0].replace(/\./g,"")
                              if(!isNaN(num)){
                              num = num.toString().split("").reverse().join("").replace(/(?=\d*\.?)(\d{3})/g,"$1,");
                              num = num.split("").reverse().join("").replace(/^[\.]/,"");  
                              costo_discount=num+"."+cost[1];
                                   }
                        }
                        total_cost.innerHTML="$ "+costo_discount +"(US)";
                         $(price_discount).html("Price with discount: "+total_cost.innerHTML);                         
                        radio2.value=costo_discount;
                        amount.value=costo_discount;
                        
                        document.getElementById('cost_discount1').innerHTML="Price with discount $ "+costo_discount;
                        document.getElementById('vdiscount1').value=objeto_json.discount;
                        document.getElementById('cdiscount1').value=costo_discount; 
                       }
                       else
                       {
                          alert('Por favor escriba o copie y pegue el codigo proporcionado');
                          document.getElementById('promotionalCode1').value=""
                           document.getElementById('value_discount1').innerHTML="";
                          document.getElementById('cost_discount1').innerHTML="";
                          document.getElementById('value_discount1').style.display="none";
                          document.getElementById('cost_discount1').style.display="none";
                       }
                          


                    }//fin de respuesta
 
              })
               

        }

}  
function showNumberConfirmation(){
          if(document.getElementById('readyPaid').checked==true){
                        document.getElementById('confirmationNumber').style.display="block";
                        document.getElementById('lblConfirmationNumber').style.display="block";
                        document.getElementById('paymentInfo').style.display="none"; 
                        document.getElementById('methodPayment').style.display="none";
                        document.getElementById('optionPago1').style.display="none";
			document.getElementById('optionPago2').style.display="none" 
                        document.getElementById('imgTarget1').style.display="none"  
                        document.getElementById('imgTarget2').style.display="none"; 
          }
          else
          {
                 document.getElementById('confirmationNumber').style.display="none";
                 document.getElementById('lblConfirmationNumber').style.display="none";
                 

          }
}
function getRadioButtonSelectedValue(ctrl)
{

if(ctrl)
{

    for(i=0;i<ctrl.length;i++)
	{
	
        if(ctrl[i].checked)
		{
			return ctrl[i].value;
		}
	}
}
else
{
return false;
}
}

