function showEstimatedMonthlySales(el){
	document.getElementById('EstimatedMonthlySales').style.display = (el.value == 3 || el.value == 4) ? '' : 'none';
}

function openURL(el,thisCurQuery,thisURL){ 
	var nameOfObj = el.name;
	var selInd = eval("document.theForm." + nameOfObj + ".selectedIndex"); 
	var dataValue = eval("document.theForm." + nameOfObj + ".options[selInd].value");
	var newAddedItem = nameOfObj + "=" + escape(dataValue);
	var newQueryString = '';
	var queryArray = new Array();
	
	queryArray = thisCurQuery.split("&")
	
	for(i = 0; i < queryArray.length; i++){
		var subQueryA = new Array();
		subQueryA = queryArray[i].split("=");
		if (subQueryA[0] == nameOfObj){
			queryArray.splice(i,1);
		}
	}
	
	for(i = 0; i < queryArray.length; i++){
		var foundPage = queryArray[i].search("page");
		if(foundPage != -1){
			queryArray.splice(i,1);
		} 	
	}	
	
	for(i = 0; i < queryArray.length; i++){
		var foundPage = queryArray[i].search("Viewall");
		if(foundPage != -1){
			queryArray.splice(i,1);
		} 	
	}
	
	for(i = 0; i < queryArray.length; i++){
		var foundPage = queryArray[i].search("x");
		if(foundPage != -1){
			queryArray.splice(i,1);
		} 	
	}	
	
	/*
	for(i = 0; i < queryArray.length; i++){
		var foundPage = queryArray[i].search("y");
		if(foundPage != -1){
			queryArray.splice(i,1);
		} 	
	}
	*/
	
	newQueryString = queryArray.join('&');
	
	if (newQueryString == ''){
		newQueryString += newAddedItem;
	} else {
		newQueryString += "&" + newAddedItem;
	}
	
	goURL = thisURL + "?" + newQueryString;
	top.location.href = goURL;
}

function confirmClick(ConfirmationMessage)
{
	if (!confirm(ConfirmationMessage))
	{
		return false;
	}
}

function updateStarStatus(customerID,status){
	var action = "add";
	if (status == 0){
		action = "delete";
	}
	
	//alert(action);
	var el = document.getElementById('star_' + customerID);
	var thisel = document.getElementById('thisStar_' + customerID);
	
	thisel.style.display = "none";
	
	//ajax begin
	el.style.display = "";
	el.innerHTML = "";
	
	xmlHttp = GetXmlHttpObject();
	
	if (xmlHttp == null){
		alert ("Browser does not support HTTP Request");
		return false;
	}
	
	var url = "../users/quote_star_update.html";
	var params = "CQSCustomerID=" + customerID + "&action=" + action;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete"){ 
			el.innerHTML = parseScript(xmlHttp.responseText);
		} 	
	}
	
	xmlHttp.send(params);
	//ajax end				
	
}

function popUpUSPSInfo(tt,descVAR){
	var Info = [];
	Info["N"] = 'This address was not confirmed by the USPS and may result in an inaccurate quote.';
	Info["Y"] = 'This address was verified by the USPS system.';
	
	var e = document.getElementById('pop_USPS');   
	var t = tt.offsetTop;
	var h = tt.clientHeight;
	var l = tt.offsetLeft;
	var ttyp = tt.type;
	while(tt = tt.offsetParent){
		t += tt.offsetTop;
		l += tt.offsetLeft;
	}
	e.style.top = (ttyp=="image")? t + h : t + h + 3;
	e.style.left = l - 100;
	e.style.display = "block";
	e.innerHTML = Info[descVAR];
}  

function handleCM(el,id){
	var cmValue = 'n';
	if (el.value == 1){
		cmValue = 'y'
	}
	
	goURL = "/carriers/carrier_user_status_update.html?CarrierUserID=" + id + "&cm=" + cmValue;
	top.location.href = goURL;
}

function handleAccessLevel(el,id){
	var thisValue = el.value;
	goURL = "/carriers/carrier_user_status_update.html?CarrierUserID=" + id + "&AccessLevel=" + thisValue;
	top.location.href = goURL;
}

function showOtherMaster(el){
	var otherMaster = document.getElementById('otherMaster');
	otherMaster.style.display = "none";	
	if (el.value == 'other'){
		otherMaster.style.display = "";		
	}
}

function handleUserManager(el,AgentsCarriersID,view){
	var CarrierUserID = el.value;
	var status = 'n';
	if (el.checked == true){
		status = 'y';
	}
	
	goURL = "/carriers/agent_assignment_update.html?AgentsCarriersID=" + AgentsCarriersID + "&CarrierUserID=" + CarrierUserID + "&status=" + status +"&view=" + view;
	top.location.href = goURL;
}

