var xmlHttp;
var UPVS_PARTNER_ID;
var DIVNAME = "upvs_quote_area";
var requestURL;
var act="";
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
function fetch_remote_page(url, action)
{ 
	
		act=action;
		requestURL = url;
	//	alert(requestURL);
		xmlHttp = GetXmlHttpObject(stateChangeHandler);
		xmlHttp_Get(xmlHttp, requestURL);
	
}
/// ADDED
function showThumb(Img)
{
	document.getElementById('change').src='extra_images/big_image/'+Img;
}

function stateChangeHandler()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		//////////////var str = xmlHttp.responseText;	//alert(str);
		var str = xmlHttp.responseText;
		alert(str);
		switch(act){
			case "CAPTCHA":
				var chk=str.split("_");
				document.getElementById("usr_avail").src='security_images/'+chk[0]+".jpg";
				document.getElementById("sessionid").value=chk[1];
			break;
			case "REFERRER":
				fetch_remote_page('http://www.siliconvalley.co.in/ajax_contact.php',"CAPTCHA");
			break
		}
	}
}

function xmlHttp_Get(xmlhttp, url)
{
	xmlhttp.open('GET', url, true);
	xmlhttp.send(null);
}

function GetXmlHttpObject(handler)
{
	var objXmlHttp = null;
	if (is_ie)
	{
		var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
		try
		{
			objXmlHttp = new ActiveXObject(strObjName);
			objXmlHttp.onreadystatechange = handler;
		}
		catch(e)
		{
			alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
			return;
		}
	}
	else if (is_opera)
	{
		alert('Opera detected. The page may not behave as expected.');
		return;
	}
	else
	{
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload = handler;
		objXmlHttp.onerror = handler;
	}
	return objXmlHttp;
}

function Initialize(){var initstring = "";initstring+="<style type='text/css'>";initstring+=".body {";initstring+="font-family: Verdana, Arial, Helvetica, sans-serif;";initstring+="font-size: 12px;";initstring+="font-weight: normal;";initstring+="color: #666666;";initstring+="}";initstring+=".btn{";initstring+="font-family: Verdana, Arial, Helvetica, sans-serif;";initstring+="font-size: 11px;";initstring+="color: #FFFFFF;";initstring+="background: #839A32;";initstring+="}";initstring+="</style>";initstring+="<div id='upvs_quote_area' style='height:140;width:600;overflow:auto'>";initstring+="<table width='100%' border='0' cellspacing='0' cellpadding='0'>";initstring+="<tr>";initstring+="<td class='body' width='180'>Shipping Material Weight : </td>";initstring+="<td class='body'><input type='text' name='weight' id='weight' style='border:1px solid #000000'>&nbsp;lbs</td>";initstring+="</tr>";initstring+="<tr>";initstring+="<td class='body'>&nbsp;</td>";initstring+="<td class='body'>&nbsp;</td>";initstring+="</tr>";initstring+="<tr>";initstring+="<td class='body' width='180'>Enter your zip code : </td>";initstring+="<td><input type='text' name='destination_zip' id='destination_zip' style='border:1px solid #000000'></td>";initstring+="</tr>";initstring+="<tr> ";initstring+="<td height='30' class='body' width='180'><input type='button' name='Submit' value='GET QUOTE' class='btn' onClick='submit_quote_data();'></td>";initstring+="<td class='body'>&nbsp;</td>";initstring+="</tr>";initstring+="</table>";initstring+="</div>";document.write(initstring);}function rightTrim(strValue){var objRegExp = /^([\w\W]*)(\b\s*)$/;if(objRegExp.test(strValue)){strValue = strValue.replace(objRegExp, '$1');}return strValue;}function leftTrim(strValue){var objRegExp = /^(\s*)(\b[\w\W]*)$/;if(objRegExp.test(strValue)){strValue = strValue.replace(objRegExp, '$2');}return strValue;}function trim(strValue){var objRegExp = /^(\s*)$/;if(objRegExp.test(strValue)){strValue = strValue.replace(objRegExp, '');if( strValue.length == 0)return strValue}objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;if(objRegExp.test(strValue)){strValue = strValue.replace(objRegExp, '$2');}return strValue;}function submit_quote_data(){var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;if(trim(document.getElementById('weight').value)=="")alert("Please enter the weight of shipping material");else if(isNaN(trim(document.getElementById('weight').value)))alert("Weight of shipping material should be numeric");else if(trim(document.getElementById('destination_zip').value)=="")alert("Please enter destination ZIP Code");else if(!objRegExp.test(trim(document.getElementById('destination_zip').value)))alert("Please enter a valid ZIP Code");else{fetch_remote_page(trim(document.getElementById('destination_zip').value), trim(document.getElementById('weight').value));		document.getElementById('upvs_quote_area').innerHTML = "<br><br><br><br>Please wait .....";	}}