//	This makes a soap call to bongo to get the estimated shipping cost on a particular product.  
//	This is for the product detail page.
//	bongo_key is set in /application.cfm	

function firstloadbongorate(item_name,item_id,item_url,billable_weight,quantity){
	var A_rate= new getbongo;
	A_rate.setForm("PSB_Bongo");
	//call the cfc
	var ws =A_rate.GetSingleRate();
	if (ws.COUNTRY !="" && ws.RATE !="") {
		var msg=document.getElementById("bongoratetext");
        if (ws.COUNTRY.length < 26) {
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b> " + ws.RATE + " USD";
		}
		else{
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b><br>" + ws.RATE + " USD";
		}
	} else {
        document.getElementById("bongoratetext").innerHTML = "<font color='red'><b>International quotes are unavailable at this time.</b></font>";
    }
}

function firstloadbongorate_spec4(countryname,item_name,item_id,item_url,billable_weight,quantity){
	// Create the ajax proxy instance.
    var B_rate = new getbongo;
    // setForm() implicitly passes the form fields to the CFC function.
	B_rate.setForm("PSB_Bongo_spec4");
    //Call the CFC validateCredentials function.
	var ws=B_rate.GetSingleRate();
	
	if (ws.COUNTRY !="" && ws.RATE !="") {
		document.getElementById("bongorates").style.display="none";
		var msg=document.getElementById("pageloadbongoratevalue");
		msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b> " + ws.RATE + " USD";
		document.getElementById("pageloadbongorates").style.display="block";
	} else {
        	var donothing=0;
    	}
}

function getBongoRatePopup() {
	// Create the ajax proxy instance.
	if (document.getElementById("bongo_country").value=='xxx'){
		alert('Please choose a country or click the cancel link to close this window.');
		return false;
	}
	
	document.getElementById("bongoratetext").style.height="20px";
	
    var B_rate = new getbongo;
    // setForm() implicitly passes the form fields to the CFC function.
	B_rate.setForm("PSB_Bongo");
    //Call the CFC validateCredentials function.
	var ws=B_rate.GetSingleRate();
	if (ws.COUNTRY !="" && ws.RATE !="") {
		var msg=document.getElementById("bongoratetext");
        if ((ws.COUNTRY.length < 20)&& (ws.COUNTRY.length !=0)) {
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b> " + ws.RATE + " USD";
		}
		else{
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b><br>" + ws.RATE + " USD";
			document.getElementById("bongoratetext").style.height="32px";
		}
		parent.updatebongocountryandrate(ws.COUNTRY,ws.RATE);		
		document.getElementById("bongoratetext").style.border="1px solid orange";
	} else {
        document.getElementById("bongoratetext").innerHTML = "<font color='red'><b>International quotes are unavailable at this time.</b></font>";
    }
}    

function getBongoRatePopup_quoteonly() {
	// Create the ajax proxy instance.
	document.getElementById("bongoratetext").style.height="20px";
    var B_rate = new getbongo;
    var savecountry=document.getElementById("bongocountryname")
    savecountry.value="no"; // change to DON'T SAVE COUNTRY
    // setForm() implicitly passes the form fields to the CFC function.
	B_rate.setForm("PSB_Bongo");
    //Call the CFC validateCredentials function.
	var ws=B_rate.GetSingleRate();
	if (ws.COUNTRY !="" && ws.RATE !="") {
		var msg=document.getElementById("bongoratetext");
        if ((ws.COUNTRY.length < 20)&& (ws.COUNTRY.length !=0)) {
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b> " + ws.RATE + " USD";
		}
		else{
			msg.innerHTML = '' +"<b>" + ws.COUNTRY + ":</b><br>" + ws.RATE + " USD";
			document.getElementById("bongoratetext").style.height="32px";
		}
		document.getElementById("bongoratetext").style.border="1px solid orange";
	} else {
        document.getElementById("bongoratetext").innerHTML = "<font color='red'><b>International quotes are unavailable at this time.</b></font>";
    }
    savecountry.value="yes"; // change save country back to  "yes"
}   

function cancelBongoPopupSession (){
	document.getElementById("bongoratetext").style.border="0px solid black";
	var kill_bongouser= new getbongo;
	var ws=kill_bongouser.cancelBongoUser();
	parent.revertbongosession();
}

function mainkillbongosession() {
	var kill_bongouser= new getbongo;
	var ws=kill_bongouser.cancelBongoUser();
	document.getElementById("bongorates").style.display="block";
	if (document.getElementById("pageloadbongorates")){
		document.getElementById("pageloadbongorates").style.display="none";
	}
}






function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=0,width=530,height=480,left = 520,top = 285');");
}