/* 
 * @author Summit Saini 
 * @company Ness Technologies Pte Ltd
 * @date 11092004
 * @description Added Javascript function(s) to open POPUP window for spell checker
 */
function LTrim(str) {
	if(str==null) {
		return null;
	}
	for(var i=0;str.charAt(i)==" ";i++);
	return str.substring(i,str.length);
}
function RTrim(str) {
	if(str==null) {
		return null;
	}
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
}
function Trim(str) {
	return LTrim(RTrim(str));
}
function spellCheck(url,idx) {
	url = url + idx;
	if (idx == "1") {
		var value=document.inquiry.inquiry_remarks.value;
		if(value != "" && value.length > 0) {
			val = Trim(value);
			if(val == "" && val.length == 0) {
				alert("Please enter some text in \"Write your message to the supplier\" textarea to perform Spell Checking");
				document.inquiry.inquiry_remarks.value="";
			} else {
				if(calChars(document.inquiry.inquiry_remarks)) {
					winPop(url, 400, 600, idx, "yes");
					document.inquiry.openWin1.value="1";
				}
			}
		} else {
			alert("Please enter some text in \"Write your message to the supplier\" textarea to perform Spell Checking");
		}
	} else if(idx == "2") {
		var value=document.inquiry.inquiry_company_information.value;
		if(value != "" && value.length > 0) {
			val = Trim(value);
			if(val == "" && val.length == 0) {
				alert("Please enter some text in \"Tell the supplier about your company\" textarea to perform Spell Checking");
				document.inquiry.inquiry_company_information.value="";
			} else {
				if(calChars(document.inquiry.inquiry_company_information)) {
					winPop(url, 400, 600, idx, "yes");
					document.inquiry.openWin2.value="1";
				}
			}
		} else {
			alert("Please enter some text in \"Tell the supplier about your company\" textarea to perform Spell Checking");
		}
	}
}
function winPop(page,height,width,windowname,scrollbars) {
	params = "height=" + height + ",width=" + width + ",status=yes,toolbar=no,directories=no,menubar=no,location=no,scrollbars=" + scrollbars + ",resizable=yes,top=50,left=50,screenX=50,screenY=50";
	popWindow = open(page,windowname,params);
}
function calChars(txField) {
	var remarks=txField.value;
	if (remarks.length >1500 ) {
		alert("Your message is too long.");
		txField.focus();
		return false;
	}	
	return true;
}	
function checkEmail(theField, fieldName, hideField) {
	if (Trim(theField.value).length>0 && checkForEmailError(theField.value)>0) {
		var errCode = checkForEmailError(theField.value);
		if (errCode == 1) {
			showBox(fieldName+"1");
			hideBox(fieldName+"2");
			pagetTracker._trackEvent('eGSOLInqForm','EmailFormatError','Business-EmailField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-OrgEmail', 'WT.error_str','EmailFmtErr','WT.rfi_status', inqFlowPath);
		} else if (errCode == 2) {
			showBox(fieldName+"2");
			hideBox(fieldName+"1");
			pagetTracker._trackEvent('eGSOLInqForm','HasSpecialCharError','Business-EmailField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-OrgEmail', 'WT.error_str','SpecialCharErr','WT.rfi_status', inqFlowPath);
		}
        //theField.value = "";
        //theField.select();
        //theField.focus();
		return false;
	} else {
		hideBox(fieldName+"1");
		hideBox(fieldName+"2");
	}
	return true;
}
function changeAction(docType) {
	var updprofile = document.inquiry.update_user_info;
	var updchecked = false;
	if(updprofile!=null) {
		if(updprofile.checked==true) {
			document.inquiry.update_user_profile.value = "yes";
			updchecked = true;
		} else {
			document.inquiry.update_user_profile.value = "no";
			updchecked = false;
		}
	}
	var origemail = document.inquiry.originalemail.value;
	var inputemail = Trim(document.inquiry.contact_detail_email.value);
	var isLoggedInUser = document.inquiry.isLoggedIn.value;
	var isCookiedInUser = document.inquiry.isCookiedIn.value
	var hasEmptyReqFld=checkFieldsOverlay(docType);
	if( hasEmptyReqFld==false && ((origemail!=inputemail && !checkForEmailError(inputemail))|| updchecked==true) && (isLoggedInUser=="true"||isCookiedInUser=="true")) {
		document.inquiry.action = document.inquiry.actionToSSO.value;
	} else {
		document.inquiry.action = document.inquiry.formaction.value;
	}
	if (document.inquiry.AGG_single_inq!=null && document.inquiry.AGG_single_inq!=undefined) {
		document.inquiry.action = document.inquiry.action + "&AGG_single_inq=" + document.inquiry.AGG_single_inq.value;
	}
	//go overlay when email is change
	if (hasEmptyReqFld==false && origemail!=inputemail && !checkForEmailError(inputemail) && (isLoggedInUser=="true"||isCookiedInUser=="true")) {
		var frameSize="width=700px,height=275px,center=1,resize=0,scrolling=0";
		if (isLoggedInUser=="true")
			frameSize="width=700px,height=170px,center=1,resize=0,scrolling=0";
		
		//alert (document.inquiry.action);
		document.inquiry.target = "_iframe-UpdateProfileBox";
		dhtmlmodal.open('UpdateProfileBox', 'iframe', document.inquiry.action, 'E-mail Address Update', frameSize);
	}
	
}
/*
 * Check required fields before displaying the SSO overlay window
 * Add new required fields below.
 */
function checkFieldsOverlay(docType) {
	var reqFields=new Array();
		reqFields[0]="inquiry_remarks";
		reqFields[1]="contact_detail_first_name";
		reqFields[2]="contact_detail_last_name";
		reqFields[3]="contact_detail_company_name";
		reqFields[4]="contact_detail_email";
		reqFields[5]="contact_detail_address_country";
		reqFields[6]="contact_detail_tel_country_code";
		reqFields[7]="contact_detail_tel_number";
		if (docType=="RFS")
			reqFields[8]="sample_quantity_str";
		var myFrm = document.inquiry;	
		var hasEmpty=false;
		for (var i=0; i<reqFields.length; i++) {
			field1=reqFields[i];
			if (myFrm[field1].value=="") {
				hasEmpty=true;
				break;
			}
}
	return hasEmpty;
}
function chkTxAreas(docType) {
	var txArea1 = document.inquiry.inquiry_remarks;
	var txArea2 = document.inquiry.inquiry_company_information;
	if (txArea1.value.length>1500 || txArea2.value.length>1500) {
		var errMsg = "The information typed in for the following fields are too long:\n";
		if (txArea1.value.length>1500 && txArea2.value.length>1500) {
            errMsg = errMsg + "* Message\n";
			errMsg = errMsg + "* Tell the supplier about your company\n";
			txArea1.focus();
		} else if (txArea1.value.length>1500) {
            errMsg = errMsg + "* Message\n";
			txArea1.focus();
		} else if (txArea2.value.length>1500) {
			errMsg = errMsg + "* Tell the supplier about your company\n";
			txArea2.focus();
		}
		errMsg = errMsg + "Please limit them to 1500 characters or less.";
		alert(errMsg);
		return false;
	}	
	//if( !isValidPhoneFaxNumbers()) {
	//	return false;
	//}
	/* 
     * @author Summit Saini 
     * @company Ness Technologies Pte Ltd
     * @date 11092004
     * @description check to open spell checker windows based on values "1" & "2"
     */
	document.inquiry.ValidateInquiry.value = "";
	var origemail = document.inquiry.originalemail.value;
	var inputemail = Trim(document.inquiry.contact_detail_email.value);
	var isLoggedInUser = document.inquiry.isLoggedIn.value;
	var isCookiedInUser = document.inquiry.isCookiedIn.value
	//don't submit if email is taken or validation in progress
	if (inputemail.length>0 && origemail!=inputemail && (isLoggedInUser=="true"||isCookiedInUser=="true")) {
		var emailExistsErrorDiv = document.getElementById("RegisteredEmail");
		var emailExistsErrorLiteDiv = document.getElementById("LiteEmail");
		if (emailValidationInProgress) { //for slow Ajax response
			return false;
		}else if (emailExistsErrorDiv.style.display == 'block' || emailExistsErrorLiteDiv.style.display == 'block') {
			//return false;
		}
	}
	if (!checkedIllegalChars()) {
		return false;
	}
	changeAction(docType);
	if (typeof GASeq != 'undefined') {
	document.inquiry.action = document.inquiry.action + "&gaseq=" + GASeq;
	}
	changeButton('buttonImage','greyImage','submIndicator');
	clearDefaultValues();
	convertFieldsToSafeText();	
	if (document.inquiry.contact_detail_email.value.length>0) {
		document.inquiry.contact_detail_email.value = Trim(document.inquiry.contact_detail_email.value);
		emailFocus();
		document.inquiry.contact_detail_email.focus();
	}
	return true;
	//return true;
}
function convertFieldsToSafeText() {
	$("#myInquiryForm textarea").each(function(i){
		var convfldVal = this.value;
		this.value = stripBrackets(convfldVal);
	})
	$("#myInquiryForm input:text").each(function(j){
		var convfldVal = this.value;
		this.value = stripBrackets(convfldVal);
	})
	$("#myInquiryForm input:hidden").each(function(j){
		var convfldVal = this.value;
		this.value = stripBrackets(convfldVal);
	})
}
function checkedIllegalChars() {
	var hasIllegalFields = false;
	$("#myInquiryForm input:text[validatefor='securetext']").each(function(j){
		var fldName = this.name;
		var labelID = "";
		var hasMandChk = "false";
		var defTxt = "";
		if (fldName=="mail_subject") { labelID = "b_subject"; }
		if (fldName=="contact_detail_first_name") { labelID = "b_name"; hasMandChk = "true"; }
		if (fldName=="contact_detail_last_name") { labelID = "b_name"; hasMandChk = "true"; }
		if (fldName=="contact_detail_company_name") { labelID = "b_companyname"; hasMandChk = "true"; }
		if (hasInsecureText(this,labelID,hasMandChk,defTxt))
			hasIllegalFields = true;
	})
	if (hasIllegalFields)
		return false;
	else
		return true;
}
function hasInsecureText(fld,labelID,hasMandatoryCheck,defaultTxt) {
	var returnVal = false;
	var chkFldVal = fld.value;
	var fldErrDiv = "MustSecureText_" + fld.name;
	if (chkFldVal.length>0 && chkFldVal!=defaultTxt) {
		var illegalChars= /[\<\>]/;
		if (chkFldVal.match(illegalChars)) {
			document.getElementById(fldErrDiv).style.display = "block";
			if (labelID!=null)
				document.getElementById(labelID).style.color = "#C00";
			returnVal = true;
		} else {
			document.getElementById(fldErrDiv).style.display = "none";
			if (labelID!=null)
				document.getElementById(labelID).style.color = "#000";
		}
	} else {
		document.getElementById(fldErrDiv).style.display = "none";
		if (labelID!=null && "true" != hasMandatoryCheck)
			document.getElementById(labelID).style.color = "#000";
	}
	return returnVal;
}
function stripBrackets(myString) {
	return myString.replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function clearDefaultValues() {
	var myFrm = document.inquiry;
	/*
	if (myFrm.contact_detail_first_name!=null && myFrm.contact_detail_first_name.value == 'First/Given Name')
		myFrm.contact_detail_first_name.value = '';
	if (myFrm.contact_detail_last_name!=null && myFrm.contact_detail_last_name.value == 'Last/Family Name')
		myFrm.contact_detail_last_name.value = '';
	if (myFrm.contact_detail_tel_area_code!=null && (myFrm.contact_detail_tel_area_code.value == 'Area Code' || myFrm.contact_detail_tel_area_code.value == 'Area C'))
		myFrm.contact_detail_tel_area_code.value = '';
	if (myFrm.contact_detail_tel_number!=null && myFrm.contact_detail_tel_number.value == 'Telephone Number')
		myFrm.contact_detail_tel_number.value = '';
	if (myFrm.contact_detail_tel_ext_number!=null && myFrm.contact_detail_tel_ext_number.value == 'Ext')
		myFrm.contact_detail_tel_ext_number.value = '';
	*/
	if (myFrm.contact_detail_fax_area_code!=null && (myFrm.contact_detail_fax_area_code.value == 'Area Code' || myFrm.contact_detail_tel_area_code.value == 'Area C'))
		myFrm.contact_detail_fax_area_code.value = '';
	if (myFrm.contact_detail_fax_number!=null && myFrm.contact_detail_fax_number.value == 'Telephone Number')
		myFrm.contact_detail_fax_number.value = '';
	if (myFrm.contact_detail_address_city!=null && myFrm.contact_detail_address_city.value == 'City')
		myFrm.contact_detail_address_city.value = '';
	if (myFrm.contact_detail_address_state!=null && myFrm.contact_detail_address_state.value == 'Province/State')
		myFrm.contact_detail_address_state.value = '';
	if (myFrm.contact_detail_address_postal_code!=null && myFrm.contact_detail_address_postal_code.value == 'Zip/Postal Code')
		myFrm.contact_detail_address_postal_code.value = '';
	if (myFrm.contact_detail_website!=null && ((Trim(myFrm.contact_detail_website.value) == 'http://') || Trim(myFrm.contact_detail_website.value).length==0))
		myFrm.contact_detail_website.value = '';
}
function initRegFields() {
	if (document.inquiry.inquiry_username.value.length>0)
		document.inquiry.inquiry_username.onblur();
	if (document.inquiry.inquiry_password.value.length>0)
		document.inquiry.inquiry_password.onblur();
	if (document.inquiry.inquiry_reenter_password.value.length>0)
		document.inquiry.inquiry_reenter_password.onblur();
	if (document.inquiry.inquiry_login_username.value.length>0)
		document.inquiry.inquiry_login_username.onblur();
	if (document.inquiry.inquiry_login_password.value.length>0)
		document.inquiry.inquiry_login_password.onblur();
	if (document.inquiry.contact_detail_email.value.length>0)
		document.inquiry.contact_detail_email.onblur();
}
//use regex method to test valid value, by Jansen Sep27, 2004
function isDecimal(s,message,field) {
	if(!(/^\d+(\.\d+)?$/.test(s))){
		alertCleanFocus("Please enter only numbers for " + message + ".",field);
		return false;
	}
	// added by Felix 24/1/2006 for MR #428
	if(s.length==10) {
		if (parseFloat(s)>parseFloat("9999999999")){
			alertCleanFocus("Please enter only numbers for " + message + ".",field);
			return false;
		}
	}
	return true;
}
function isValidPhoneFaxNumbers() {
	return (isValidPhoneNumber(true) && isValidFaxNumber(true));
}
function isValidPhoneNumber(input) {
	var varTelNum = document.inquiry.contact_detail_tel_number;
	if(input) {
		if(document.inquiry.contact_detail_tel_country_code.value.length>0 && !isNum(document.inquiry.contact_detail_tel_country_code,"telephone country code"))
			return false;
		if(document.inquiry.contact_detail_tel_area_code.value.length>0 && !isNum(document.inquiry.contact_detail_tel_area_code,"telephone area code"))
			return false;
	}
	if(varTelNum.value.length>0) {
		if(!(/^\d+([ \-\d]*\d)?$/.test(varTelNum.value))) {
			alertCleanFocus("Please enter only numbers for your Telephone Number. You may separate the numbers with a space or dash.",varTelNum);
			return false;
		}
	}
	if(input) {
		if(document.inquiry.contact_detail_tel_ext_number.length>0 && !isNum(document.inquiry.contact_detail_tel_ext_number,"telephone extension"))
			return false;
	}
    return true;
}
function isValidFaxNumber(input) {
	var varFaxNum=document.inquiry.contact_detail_fax_number;
	if(input) {
		if(document.inquiry.contact_detail_fax_country_code.length>0 && !isNum(document.inquiry.contact_detail_fax_country_code,"fax country code"))
			return false;
		if(document.inquiry.contact_detail_fax_area_code.length>0 && document.inquiry.contact_detail_fax_area_code.value!='Area Code' && document.inquiry.contact_detail_fax_area_code.value!='Area C' && !isNum(document.inquiry.contact_detail_fax_area_code,"fax area code"))
			return false;
	}
    if(varFaxNum.value.length>0 && varFaxNum.value!='Telephone Number') {
		if(!(/^\d+([ \-\d]*\d)?$/.test(varFaxNum.value))) {
			alertCleanFocus("Please enter only numbers for your Fax Number. You may separate the numbers with a space or dash.",varFaxNum);
			return false;
		}
	}
    return true;
}
//for login fields checking
function displayAlert() {
	if (document.formLogin.UserID.value == "") {
		alert("Please enter Login Name.")	
		document.formLogin.UserID.focus();
		return false;
	}
	if (document.formLogin.UserPassword.value == "" ) {
		alert("Please enter Password.")
		document.formLogin.UserPassword.focus();
		return false;
	}
	return true;
}
//for opening sample company description
function openViewSample(_link) {
	msg=open(_link,"SettingsViewSample","height=290,width=480,status=0,toolbar=0,directories=0,menubar=0,location=0,scrollbars=0,resizable=0,top=50,left=50");
}
/* 
 * @author Summit Saini 
 * @company Ness Technologies Pte Ltd
 * @date 10052004
 * @description javascript function to open attachment page
 */
function gotoAttachSection(url) {
	document.inquiry.inquiry_remarks.disabled = false;
	document.inquiry.inquiry_company_information.disabled = false;
	url = url + "&inquiry_path=" + document.inquiry.inquiry_path.value;
	document.inquiry.action = url;
	document.inquiry.method = "POST";
	document.inquiry.submit();
}
/* 
 * @author Summit Saini 
 * @company Ness Technologies Pte Ltd
 * @date 1129004
 * @description javascript function to disable Textareas
 */
function disableWin(txt1, txt2) {
	if(txt1 == "1")
		document.inquiry.inquiry_remarks.disabled=true;
	else
		document.inquiry.inquiry_remarks.disabled=false;
	if(txt2 == "1")
		document.inquiry.inquiry_company_information.disabled=true;
	else
		document.inquiry.inquiry_company_information.disabled=false;
}
// from jspopup and jspopuphelp
function pop(page,height,width,scrollbr) {
	params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=" + (scrollbr!=null?scrollbr:"1") + ",resizable=1,top=50,left=50,screenX=50,screenY=50";
	mypopup = window.open(page,"PopupWindow",params);
	mypopup.focus();
}
function popup(page,height,width) {
	params = "height=" + height + ",width=" + width + ",status=no,toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,resizable=yes,top=50,left=50,screenX=50,screenY=50"
	popHelp = open(page,"HelpWindow",params);
	popHelp.focus();
}
/* for hiding and showing stuff */
function showHide(elemID,imageID,plusURL,minusURL) {
	if (document.getElementById) {
		if (document.getElementById(elemID).style.display == "block") {
			document.getElementById(elemID).style.display = "none";
			document.images[imageID].src = plusURL;
		} else {
			document.getElementById(elemID).style.display = "block";
			document.images[imageID].src = minusURL;
		}
	} else if (document.layers) {
		if (document[elemID].display == "block") {
			document[elemID].display = "none";
			document.images[imageID].src = plusURL;
		} else {
			document[elemID].display = "block";
			document.images[imageID].src = minusURL;
		}
	}
}
function showBox(elemID) {
	if (document.getElementById && document.getElementById(elemID)!=null) {
		setTimeout(function(){document.getElementById(elemID).style.display = "block";}, 10);
		//document.getElementById(elemID).style.display = "block";
	} else if (document.layers && document[elemID]!=null) {
		setTimeout(function(){document[elemID].display = "block";}, 10);
		//document[elemID].display = "block";
	}
}
function hideBox(elemID) {
	if (document.getElementById && document.getElementById(elemID)!=null) {
		setTimeout(function(){document.getElementById(elemID).style.display = "none";}, 10);
		//document.getElementById(elemID).style.display = "none";
	} else if (document.layers && document[elemID]!=null) {
		setTimeout(function(){document[elemID].display = "none";}, 10);
		//document[elemID].display = "none";
	}
}
function changeButton(elemID1, elemID2, elemID3) {
	if (document.getElementById) {
		//document.getElementById(elemID1).style.display = "none";
		//document.getElementById(elemID2).style.display = "block";
		document.getElementById(elemID3).style.display = "block";
	} else if (document.layers) {
		//document[elemID1].display = "none";
		//document[elemID2].display = "block";
		document[elemID3].display = "block";
	}
}
function isNum(field) {
	if(field.value.length>0){
		if(!(/^[0-9]+$/.test(field.value))) {
			return false;
		}
	}
	return true;
}
function isPhone(field) {
	if(field.value.length>0) {
		if(!(/^\d+([ \-\d]*\d)?$/.test(Trim(field.value)))) {
			return false;
		}
	}
	return true;
}
function alertCleanFocus(alertMsg,field){
	if (field!=null) {
		if (alertMsg.length>0)
			alert(alertMsg);
		field.focus();
		field.value="";
	}
}
function validatePhone(myForm,invalidElemID,reqdElemID,labelDiv,fieldNm) {
	if (
	(myForm.contact_detail_tel_country_code.value.length>0 && !isNum(myForm.contact_detail_tel_country_code))
	||
	(myForm.contact_detail_tel_ext_number.value.length>0 && !isNum(myForm.contact_detail_tel_ext_number))
	||
	(myForm.contact_detail_tel_area_code.value.length>0 && !isNum(myForm.contact_detail_tel_area_code))
	||
	(myForm.contact_detail_tel_number.value.length>0 && !isPhone(myForm.contact_detail_tel_number))
	 ) {
		hideBox(reqdElemID);
		showBox(invalidElemID);
		pagetTracker._trackEvent('eGSOLInqForm','NumberFormatError','PhoneNumberField',GASeq++);
		if (myForm.contact_detail_tel_country_code.value.length>0 && !isNum(myForm.contact_detail_tel_country_code)) {
			//myForm.contact_detail_tel_country_code.value = "";
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-TelCtry', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);
		} else if (myForm.contact_detail_tel_area_code.value.length>0 && !isNum(myForm.contact_detail_tel_area_code)) {
			//myForm.contact_detail_tel_area_code.value = "";
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-TelArea', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);
		} else if (myForm.contact_detail_tel_ext_number.value.length>0 && !isNum(myForm.contact_detail_tel_ext_number)) {
			//myForm.contact_detail_tel_ext_number.value = "";
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-TelExt', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);
		} else if (myForm.contact_detail_tel_number.value.length>0 && !isPhone(myForm.contact_detail_tel_number)) {
			//myForm.contact_detail_tel_number.value = "";
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Tel', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);
		}
		document.getElementById(labelDiv).style.color = "#CC0000";
	} else if (myForm.contact_detail_tel_country_code.value.length==0 || myForm.contact_detail_tel_number.value.length==0) {
		//hideBox(invalidElemID); -- they said nevermind this fix -.-
		//document.getElementById(labelDiv).style.color = "#000000";
		if ((myForm.contact_detail_tel_country_code.value.length==0 && fieldNm=='contact_detail_tel_country_code') || (myForm.contact_detail_tel_number.value.length==0 && fieldNm=='contact_detail_tel_number')) {
			hideBox(invalidElemID);
			showBox(reqdElemID);
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','PhoneNumberField',GASeq++);
			if (myForm.contact_detail_tel_country_code.value.length==0 && fieldNm=='contact_detail_tel_country_code') {
				dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-TelCtry', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
			} else if (myForm.contact_detail_tel_number.value.length==0 && fieldNm=='contact_detail_tel_number') {
				dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Tel', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
			}
			document.getElementById(labelDiv).style.color = "#CC0000";
		}
	} else {
		hideBox(invalidElemID);
		hideBox(reqdElemID);
		document.getElementById(labelDiv).style.color = "#000000";
	}
}
function validateFax(myForm,elemID,bID) {
	if (
	(myForm.contact_detail_fax_country_code.value.length>0 && !isNum(myForm.contact_detail_fax_country_code))
	||
	(myForm.contact_detail_fax_area_code.value.length>0 && myForm.contact_detail_fax_area_code.value!='Area Code' && myForm.contact_detail_fax_area_code.value!='Area C' && !isNum(myForm.contact_detail_fax_area_code))
	||
	(myForm.contact_detail_fax_number.value.length>0 && myForm.contact_detail_fax_number.value!='Telephone Number' && !isPhone(myForm.contact_detail_fax_number))
	) {
		showBox(elemID);
		pagetTracker._trackEvent('eGSOLInqForm','NumberFormatError','FaxNumberField',GASeq++);
		dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Fax', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);		
		if (myForm.contact_detail_fax_country_code.value.length>0 && !isNum(myForm.contact_detail_fax_country_code)) {
			myForm.contact_detail_fax_country_code.value = "";
			document.getElementById(bID).style.color = "#C00";
		} else if (myForm.contact_detail_fax_area_code.value.length>0 && myForm.contact_detail_fax_area_code.value!='Area Code' && myForm.contact_detail_fax_area_code.value!='Area C' && !isNum(myForm.contact_detail_fax_area_code)) {
			myForm.contact_detail_fax_area_code.value = "";
			blurFieldWithDefault(myForm.contact_detail_fax_area_code,'Area Code');
			document.getElementById(bID).style.color = "#C00";
		} else if (myForm.contact_detail_fax_number.value.length>0 && !isPhone(myForm.contact_detail_fax_number)) {
			myForm.contact_detail_fax_number.value = "";
			blurFieldWithDefault(myForm.contact_detail_fax_number,'Telephone Number');
			document.getElementById(bID).style.color = "#C00";
		}
	} else {
		hideBox(elemID);
		document.getElementById(bID).style.color = "#000";
	}
}
function validateNumber(field,elemID) {
	if (!isNum(field)) {
		showBox(elemID);
		pagetTracker._trackEvent('eGSOLInqForm','NumberFormatError','YearEstablishedField',GASeq++);
		dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-YearEst', 'WT.error_str','NumFmtErr','WT.rfi_status', inqFlowPath);
		//alertCleanFocus("",field);
	} else {
		hideBox(elemID);
	}
}
function checkFilledFullName(myForm,elemID) {
	firstName = Trim(myForm.contact_detail_first_name.value);
	lastName = Trim(myForm.contact_detail_last_name.value);
	if (firstName.length<=0 || lastName.length<=0) {
		showBox(elemID);
	} else {
		hideBox(elemID);
	}
}
function clickFieldWithDefault(fldObj,defaultString) {
	if (fldObj.value==defaultString) {
		fldObj.value = '';
	}
	fldObj.className = 'textinput';
}
function blurFieldWithDefault(fldObj,defaultString) {
	if (fldObj.value=='') {
		fldObj.className = 'textinputunfilled';
		fldObj.value = defaultString;
	}
}

function checkValidURL(fldObj,elemID,bID){
	var trimmedfldVal = Trim(fldObj.value);
	var retVal = true;
	var dot = ".";
	if ((trimmedfldVal.length==0) || (trimmedfldVal=="http://") || (trimmedfldVal.indexOf(dot)>=0)) {
		hideBox(elemID);
		document.getElementById(bID).style.color = "#000";
		fldObj.value = trimmedfldVal;
	} else {
		showBox(elemID);
		retVal = false;
		document.getElementById(bID).style.color = "#c00";
	}
	return retVal;
}

function checkFilledMandatory(fldObj,elemID,fldType,trimBool,defaultString) {
	var retVal = true;
	if (fldType == "value") {
		if (trimBool!=null && trimBool==false) {
			fldVal = fldObj.value;
		} else {
			fldVal = Trim(fldObj.value);
		}
		if (fldVal == defaultString) {
			showBox(elemID);
			retVal = false;
		} else {
			if (fldVal.length <= 0) {
				if (fldObj.name == "contact_detail_email"){
					hideBox('InvalidEmail1');
					hideBox('InvalidEmail2');				
					hideBox('RegisteredEmail');
					hideBox('LiteEmail');
				}
				showBox(elemID);
				retVal = false;
			} else {
				hideBox(elemID);
			}
		}
	}
	if (fldType == "select") {
		fldValIdx = fldObj.selectedIndex;
		if (fldValIdx <= 0) {
			showBox(elemID);
			retVal = false;
		} else {
			hideBox(elemID);
		}
	}
	if (!retVal){
		if (fldObj.name == "inquiry_remarks"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','MessageField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Msg', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "contact_detail_first_name"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','FirstNameField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-FirstName', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "contact_detail_last_name"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','LastNameField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-LastName', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "contact_detail_email"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','Business-EmailField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-OrgEmail', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "contact_detail_company_name"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','CompanyNameField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Org', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "contact_detail_address_country"){
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','CountryField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-Country', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		} else if (fldObj.name == "sample_quantity_str"){
			pagetTracker._trackEvent('eGSOLInqForm','SampleNumberError','SampleField',GASeq++);
			dcsMultiTrack('DCS.dcsuri', '/RFS-Err.htm', 'WT.ti', 'RFS Err', 'WT.si_n', 'RFS', 'WT.si_p', 'RFS-NumSample', 'WT.error_str','EmptyFieldErr','WT.rfi_status', inqFlowPath);
		}
	}
	return retVal;
}
function checkValuesMatch(fldObj,elemID,matchFldObj) {
	var retVal = true;
	if (fldObj.value.length>0 && matchFldObj.value.length>0) {
		if (fldObj.value != matchFldObj.value) {
			showBox(elemID);
			retVal = false;
		} else {
			hideBox(elemID);
		}
	}
	return retVal;
}
function showTipIfHidden(elemIDShow, elemIDHidden) {
	if (document.getElementById) {
		if (document.getElementById(elemIDHidden).style.display != "block") {
			document.getElementById(elemIDShow).style.display = "block";
		}
	} else if (document.layers) {
		if (document[elemIDHidden].display != "block") {
			document[elemID].display = "block";
		}
	}
}
function limitTextArea(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}
function compareValues(inputField,compareFieldValue,elemID) {
	if (Trim(inputField.value) == Trim(compareFieldValue)) {
		showBox(elemID);
	} else {
		hideBox(elemID);
	}
}
function checkMandatoryPair(field1,field2,elemID,inErrPage) {
	if (inErrPage == "no") {
		if ((Trim(field1.value).length>0) || (Trim(field2.value).length>0)) {
			hideBox(elemID);
		}
	}
}
function checkMandatoryPair(field1,field2,elemID) {
    if (field1 == 'country_code' && field2 =='tel_number')  {
        if (Trim(document.inquiry.contact_detail_tel_country_code.value).length <= 0 || Trim(document.inquiry.contact_detail_tel_number.value).length <= 0){
			showBox(elemID);
			pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','PhoneNumberField',GASeq++);
		} else {
			hideBox(elemID);
		}
	}
}
/**
 * This method is only used for checking Phone number
 */
function checkMandatoryPhoneNumber(field, elemID, defaultString) {
	var phoneFldVal = field.value;
	if (defaultString != null && defaultString.length>0) {
		if (phoneFldVal ==  defaultString)
			phoneFldVal = '';
	}
    if (Trim(phoneFldVal).length<=0)
    {
		showBox(elemID);
		pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','PhoneNumberField',GASeq++);
	} else {
		hideBox(elemID);
	}
}
function checkMandatoryPairWithDefault(field1,defaultString1,field2,defaultString2,elemID) {
	if (Trim(field1.value).length <= 0 || field1.value==defaultString1 || Trim(field2.value).length <= 0 || field2.value==defaultString2){
		showBox(elemID);
		pagetTracker._trackEvent('eGSOLInqForm','EmptyFieldError','PhoneNumberField',GASeq++);
	} else {
		hideBox(elemID);
	}
}
function showHideRows(elemID,imageID,plusURL,minusURL,linkObjID,copyForPlus,copyForMinus) {
	if (document.getElementById(elemID).style.display == "block") {
		document.getElementById(elemID).style.display = "none";
		document.images[imageID].src = plusURL;
		document.getElementById(linkObjID).innerHTML = copyForPlus;
	} else {
		document.getElementById(elemID).style.display = "block";
		document.images[imageID].src = minusURL;
		document.getElementById(linkObjID).innerHTML = copyForMinus;
	}
}
function showHideLabelAndField(elemID,imageID,plusURL,minusURL,linkObjID,copyForPlus,copyForMinus) {
	var fieldObjID = elemID + "FLD";
	var labelObjID = elemID + "LABEL";
	if (document.getElementById(fieldObjID).style.display == "block") {
		document.getElementById(fieldObjID).style.display = "none";
		document.getElementById(labelObjID).style.display = "none";
		document.images[imageID].src = plusURL;
		document.getElementById(linkObjID).innerHTML = copyForPlus;
	} else {
		document.getElementById(fieldObjID).style.display = "block";
		document.getElementById(labelObjID).style.display = "block";
		document.images[imageID].src = minusURL;
		document.getElementById(linkObjID).innerHTML = copyForMinus;
	}
}
function showProdTN(largeImgURL) {
	imgWinDiv.innerHTML = "<img src='" + largeImgURL + "' border='1' >";
}
function hideProdTN() {
	imgWinDiv.innerHTML = "";
}
function move_layer(event){
	event = event || window.event;
	imgWinDiv.style.left=event.clientX+document.body.scrollLeft+1;
	imgWinDiv.style.top =event.clientY+document.body.scrollTop+1;
}
function countMsgChar(limitNum,txtareaObj,cntSpanObj){
	var spanWithCount = document.getElementById(cntSpanObj);
	var summ = txtareaObj.value.replace(/[^\x00-\xff]/g,"aa");
	if(summ.length<=limitNum) {
		spanWithCount.innerHTML=summ.length;
	} else {
		txtareaObj.value = txtareaObj.value.toString().substr(0, limitNum);
		spanWithCount.innerHTML=limitNum;
	}
}
/** Added for Product Mouse Over MR **/
function getPPPosition(tag){
	var Position =[0,0];
	while(tag){
		tn=tag.tagName.toUpperCase();
		Position[0]+=tag.offsetLeft-(tn=="DIV"&&tag.scrollLeft?tag.scrollLeft:0);
		Position[1]+=tag.offsetTop-(tn=="DIV"&&tag.scrollTop?tag.scrollTop:0);
		if(tn=="BODY") break;
		tag=tag.offsetParent;
	}
	return Position;
}
function showPPSummary(e,prodID){
	try {
		clearTimeout(timer);
	} catch(s) {}

	eventElement=e.target||e.srcElement;
	var elementSrc = eventElement.src;
	var elementAlt = eventElement.alt;
	var elementParentHref = eventElement.parentNode.href;
	
	var toUse = prodID;
	var myProdDir = toUse.substring(toUse.length-3,toUse.length);
	//var src = "http://pdt.static.dev.globalsources.com/IMAGES/PDT/THUMB/" + myProdDir + "/T" + toUse + ".jpg";
	var src = "http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/pdt.static.globalsources.com/IMAGES/PDT/THUMB/" + myProdDir + "/T" + toUse + ".jpg";
	
	var xy = getPPPosition(eventElement);
	var showF = $$("showFrame");
	showF.style.left = (xy[0]-(imgWidth+3))+"px";
	showF.style.top = (xy[1]-overTop )+"px";
	showF.style.display = "block";
	$$("showFrame_img").src = src;
	$$("showFrame_img").alt = elementAlt;
	$$("showFrame_img").parentNode.href = elementParentHref;
}
function showPPOut(){
	timer = setTimeout("donePPOut()",500);
}
function donePPOut(){
	$$("showFrame").style.display = "none";
}
function clearPPTimer(){
	try {
		clearTimeout(timer);
	} catch(s) {}
}
/*Add for MR 16487*/
function changeLabelBackgd(fldObj,fldType,tdID,bID,srcPink,srcBlue) {
	if (fldType == "value") {
		fldVal = Trim(fldObj.value);
		if (fldVal.length <= 0) {
			//document.getElementById(tdID).style.backgroundImage = 'url(' + srcPink + ')';
            document.getElementById(bID).style.color = "#CC0000";
		} else {
			//document.getElementById(tdID).style.backgroundImage = 'url(' + srcBlue + ')';
            document.getElementById(bID).style.color = "#000000";
		}
	}
	if (fldType == "select") {
		fldValIdx = fldObj.selectedIndex;
		if (fldValIdx <= 0) {
			//document.getElementById(tdID).style.backgroundImage = 'url(' + srcPink + ')';
            document.getElementById(bID).style.color = "#CC0000";
		} else {
			//document.getElementById(tdID).style.backgroundImage = 'url(' + srcBlue + ')';
            document.getElementById(bID).style.color = "#000000";
		}
	}
}
function changeLabelBackground(fldObj,fldName,bID) {
	if (fldName == "email") {
		//fldVal = Trim(fldObj.value);
		if (document.getElementById('ReqdEmail').style.display == "block" || document.getElementById('RegisteredEmail').style.display == "block" || document.getElementById('LiteEmail').style.display == "block" || document.getElementById('InvalidEmail1').style.display == "block" || document.getElementById('InvalidEmail2').style.display == "block"){
            document.getElementById(bID).style.color = "#CC0000";
		} else {
			document.getElementById(bID).style.color = "#000000";
		}
	}
}
function changeNumLabelBackgd(field,tdID,bID,srcPink) {
	if (!isNum(field)) {
		//document.getElementById(tdID).style.backgroundImage = 'url(' + srcPink + ')';
        document.getElementById(bID).style.color = "#CC0000";
	} else {
		//document.getElementById(tdID).style.backgroundImage = '';
        document.getElementById(bID).style.color = "#000000";
	}
}
function changeFaxBg(myForm,tdID,bID,srcPink) {
	if (!isNum(myForm.contact_detail_fax_country_code) || !isNum(myForm.contact_detail_fax_area_code) || !isPhone(myForm.contact_detail_fax_number)) {
		//document.getElementById(tdID).style.backgroundImage = 'url(' + srcPink + ')';
        document.getElementById(bID).style.color = "#CC0000";
	} else {
		//document.getElementById(tdID).style.backgroundImage = '';
        document.getElementById(bID).style.color = "#000000";
	}
}
function changePhoneBg(myForm,tdID,bID,srcPink,srcBlue) {
	if (
	(myForm.contact_detail_tel_country_code.value.length>0 && !isNum(myForm.contact_detail_tel_country_code))
	||
	(myForm.contact_detail_tel_ext_number.value.length>0 && !isNum(myForm.contact_detail_tel_ext_number))
	||
	(myForm.contact_detail_tel_area_code.value.length>0 && !isNum(myForm.contact_detail_tel_area_code))
	||
	(myForm.contact_detail_tel_number.value.length>0 && !isPhone(myForm.contact_detail_tel_number))) {
        document.getElementById(bID).style.color = "#CC0000";
	} else if (
	Trim(document.inquiry.contact_detail_tel_country_code.value).length <= 0
	||
	Trim(document.inquiry.contact_detail_tel_number.value).length <= 0
	) {
        document.getElementById(bID).style.color = "#CC0000";
	}else {
        document.getElementById(bID).style.color = "#000000";
	}
}
function changePhoneBgByFld(field,tdID,bID,srcPink,srcBlue) {
	if (field.name=='contact_detail_tel_country_code'){
		if (field.value.length>0 && !isNum(field)){
			document.getElementById(bID).style.color = "#CC0000";
		} else {
			document.getElementById(bID).style.color = "#000000";
		}	
	}

	if(field.name=='contact_detail_tel_area_code'){
		if (field.value.length>0 && !isNum(field))
		{
			document.getElementById(bID).style.color = "#CC0000";
		} else {
			document.getElementById(bID).style.color = "#000000";
		}
	}
	
	if(field.name=='contact_detail_tel_number'){
		if (field.value.length>0 && !isPhone(field)) 
		{
			document.getElementById(bID).style.color = "#CC0000";
		} else {
			document.getElementById(bID).style.color = "#000000";
		}
	}

	if(field.name=='contact_detail_tel_ext_number'){
		if (field.value.length>0 && !isNum(field))
		{    
			document.getElementById(bID).style.color = "#CC0000";
		} else {
			document.getElementById(bID).style.color = "#000000";
		}
	}
	
	if (document.getElementById("InvalidPhone").style.display=="block" 
		|| document.getElementById("ReqdPhone").style.display=="block")
	{
		document.getElementById(bID).style.color = "#CC0000";
	} else {
	    document.getElementById(bID).style.color = "#000000";
	}
}
function changeNameBg(field,defaultString) {
    if (field == 'first_name')  {
        if ((Trim(document.inquiry.contact_detail_first_name.value).length <= 0) || (document.inquiry.contact_detail_first_name.value == defaultString))  {
            document.getElementById('b_name').style.color = "#CC0000";
        } else {
            document.getElementById('b_name').style.color = "#000000";
        }
    }

    if (field == 'last_name')  {
        if ((Trim(document.inquiry.contact_detail_last_name.value).length <= 0) || (document.inquiry.contact_detail_last_name.value == defaultString))  {
            document.getElementById('b_name').style.color = "#CC0000";
        } else {
            document.getElementById('b_name').style.color = "#000000";
        }
    }
}
function showTipWithError(errBox,TipBox) {
    if (document.getElementById(errBox).style.display == "block"){
    	setTimeout(function(){document.getElementById(TipBox).style.display = "block";}, 10);
        //document.getElementById(TipBox).style.display = "block";
    } else {
    	setTimeout(function(){document.getElementById(TipBox).style.display = "none";}, 10);
        //document.getElementById(TipBox).style.display = "none";
    }
}
function showEmailTipWithError() {
    if (document.getElementById('RegisteredEmail').style.display == "block"
    	|| document.getElementById('LiteEmail').style.display == "block"
        || document.getElementById('ReqdEmail').style.display == "block"
        ||document.getElementById('InvalidEmail1').style.display == "block"
        ||document.getElementById('InvalidEmail2').style.display == "block") {
        document.getElementById('TipEmail').style.display = "block";
    } else {
    	setTimeout(function(){document.getElementById('TipEmail').style.display = "none";}, 10)
        //document.getElementById('TipEmail').style.display = "none";
    }
}
function syncWithUVCheckbox(cbox,uvURL,flURL) {
	if (cbox.checked) {
		document.inquiry.uv_endeca_query_string.value=uvURL;
		document.inquiry.AGG_single_inq.value="Y";
		document.getElementById("uvToText").style.display = "inline";
		if (flURL!=null && document.inquiry.uv_fl_endeca_query_string!=null) {
			document.inquiry.uv_fl_endeca_query_string.value = flURL;
		}
	} else {
		document.inquiry.uv_endeca_query_string.value='';
		document.inquiry.AGG_single_inq.value="N";
		document.getElementById("uvToText").style.display = "none";
		if (flURL!=null && document.inquiry.uv_fl_endeca_query_string!=null) {
			document.inquiry.uv_fl_endeca_query_string.value = '';
		}
	}
}
function changeInqType(origInqAllVal,myNewInqFormURL) {
	var goToURL = myNewInqFormURL;
	if (document.inquiry.expand_type!=null && document.inquiry.expand_type!=undefined) {
		if (document.inquiry.expand_type.checked) {
			goToURL = goToURL + "&expand_type=" + document.inquiry.expand_type.value;
		}
	}
	changeInqPath();
	document.inquiry.action = goToURL + "&inquiry_path=" + document.inquiry.inquiry_path.value + "&refresh=true";
	clearDefaultValues();
	convertFieldsToSafeText();
	document.inquiry.submit();
}
function changeInqPath() {
	var inqAllBoxExists = (document.inquiry.inquire_all_now!=null && document.inquiry.inquire_all_now!=undefined);
	var uvInqAllBoxExists = (document.inquiry.expand_type!=null && document.inquiry.expand_type!=undefined);
	var isSingleUVandUpsellingV = (uvInqAllBoxExists && document.inquiry.expand_type.value == "vnow");
	if (inqAllBoxExists && document.inquiry.inquire_all_now.checked==true && uvInqAllBoxExists && document.inquiry.expand_type.checked==true) {
		document.inquiry.inquiry_path.value = "InquireAll_OnePPAll" + "_" + origInqPath;
	} else if (inqAllBoxExists && document.inquiry.inquire_all_now.checked==true && (!uvInqAllBoxExists || (uvInqAllBoxExists && document.inquiry.expand_type.checked==false))) {
		document.inquiry.inquiry_path.value = "InquireAll_OnePP" + "_" + origInqPath;
	} else if (uvInqAllBoxExists && document.inquiry.expand_type.checked==true && (!inqAllBoxExists || (inqAllBoxExists && document.inquiry.inquire_all_now.checked==false))) {
		if (document.inquiry.inquiry_path.value.indexOf("InquireAll_OneSP")<0) {
			if (isSingleUVandUpsellingV) {
				document.inquiry.inquiry_path.value = "InquireAll_VerPP" + "_" + origInqPath;
			} else {
				document.inquiry.inquiry_path.value = "InquireAll_OnePPAGG" + "_" + origInqPath;
			}
		}
	} else {
		if (document.inquiry.inquiry_path.value.indexOf("InquireAll_OneSP")<0) {
			document.inquiry.inquiry_path.value = origInqPath;
		}
	//alert(document.inquiry.inquiry_path.value);
        }
}
function toggleInquireAllNow(inqAllProdCount, checkboxStatus, inqAllToggleStr) {
	var origInqAllVal = (checkboxStatus == "")?"false":"true";
	if (document.inquiry.inquire_all_now.checked && inqAllProdCount>0) {
		document.inquiry.inquire_all_now.disabled=true;
		changeInqType(origInqAllVal, inqAllToggleStr+"&inqAll=N"+"&inqall_msg=Y");
	} else if (!document.inquiry.inquire_all_now.checked) {
		document.inquiry.inquire_all_now.disabled=true;
		changeInqType(origInqAllVal, inqAllToggleStr + "&inqAll=N");
	}
}
function popInqAllTipbox() {
	if(document.getElementById("inqall_msg_anchor").checked == true){
		document.getElementById("tips_CKBox").style.display = "block";
		setTimeout(function(){
			document.getElementById("tips_CKBox").style.display = "none";
		},5000);
	} else {
		document.getElementById("tips_CKBox").style.display = "none";
	}
}

/**
  * Scripts for V96
  **/
var userClickedPABox = false;
function switchTab(tabType) {
	// tabType values: "NEW" or "CURRENT"
	if (tabType == "NEW") {
		document.inquiry.tabtype[0].checked = true;
		document.getElementById('InqTabNewUser').style.display='block';
		document.getElementById('tabText').innerHTML='Your Contact Details to Supplier:';
		//document.getElementById('tabNewTD').className='tabCurrent';
		//document.getElementById('tabCurrentTD').className='tabBehind';
		document.getElementById('InqTabCurrentUser').style.display='none';
		document.getElementById('notificationsbox').style.display='block';
		if (!userClickedPABox && document.inquiry.add_cats_to_prefs!=null && document.inquiry.add_cats_to_prefs!=undefined) {
			document.inquiry.add_cats_to_prefs.checked = true;
			document.inquiry.add_cats_checked.value = "yes";
		}
		if (document.getElementById('AlreadyTakenInquiryEmail')!=null && document.getElementById('AlreadyTakenInquiryEmail').style.display=='block') {
			document.inquiry.contact_detail_email.focus();
		}
	} else if (tabType == "CURRENT") {
		document.inquiry.tabtype[1].checked = true;
		document.getElementById('InqTabCurrentUser').style.display='block';
		document.getElementById('tabText').innerHTML='Sign In to Send Your Inquiry:';
		//document.getElementById('tabCurrentTD').className='tabCurrent';
		//document.getElementById('tabNewTD').className='tabBehind';
		document.getElementById('InqTabNewUser').style.display='none';
		document.getElementById('notificationsbox').style.display='none';
		if (!userClickedPABox && document.inquiry.add_cats_to_prefs!=null && document.inquiry.add_cats_to_prefs!=undefined) {
			document.inquiry.add_cats_to_prefs.checked = false;
			document.inquiry.add_cats_checked.value = "no";
		}
	}
}
function checkFieldIsNotInError(isNotInErr1,isNotInErr2,tdID,bID,srcPink,srcBlue) {
	if (isNotInErr1 && isNotInErr2) {
		//document.getElementById(tdID).style.backgroundImage = 'url(' + srcBlue + ')';
		document.getElementById(bID).style.color = "#000000";
	} else {
		//document.getElementById(tdID).style.backgroundImage = 'url(' + srcPink + ')';
		document.getElementById(bID).style.color = "#CC0000";
	}
}
/* Added for new attach flow */
function fileAdded(file, response, icon, blank, removeAttURL) {
      var fileVal=response.split('|');
      //SUCCESS|Id|FileName|MimeType|Size
      var fileArr=new Array(4); 
      for (var i=1; i<fileVal.length; i++) {
          fileArr[i]=fileVal[i]
      }
      var attachID=fileArr[1];
      var fileSizeOrig=Trim(fileArr[4]);
      fileSize=fileSizeOrig/1024; //show in xK format
      var dec = (fileSizeOrig%1024!=0? 2 : 0);
      var fileName=Trim(file);
      var mimeType=Trim(fileArr[3]);
      removeAttURL+="&attachment_id="+attachID; //append id
      var newFileAdded='<span class=\"black_text\" id=\"'+attachID+'\" style=\"display:block;\"><img src=\"'+icon+'\" width=\"9\" height=\"14\" align=\"absmiddle\">&nbsp;'
            +fileName+'&nbsp;('+mimeType+')&nbsp;'+fileSize.toFixed(dec)+'K'
            +'<img src=\"'+blank+'\" width=\"10\" height=\"5\"> <a href=\"#\" onClick=\"removeAttachment(\''+removeAttURL+'\',\''+attachID+'\');return false;\">Remove</a><br>'      
            //+'<input type=\"hidden\" name=\"orig_Attachment_ID\" value=\"'+attachID+'\">'
            +'<input type=\"hidden\" name=\"Attachment_ID\" value=\"'+attachID+'\">'
            +'<input type=\"hidden\" name=\"File_Name\" value=\"'+fileName+'\">'
            +'<input type=\"hidden\" name=\"File_Size\" value=\"'+fileSizeOrig+'\">'
            +'<input type=\"hidden\" name=\"Mime_Type\" value=\"'+mimeType+'\"></span>';
     return newFileAdded;
}
function removeAttachment(removeAttURL, attachID) {
    //do ajax call.
    var isDeleted = false;
    var responseText = null;
    $.ajax({
        type:"GET", 
        url:removeAttURL, 				
        dataType:"html", 
        cache: false,
        error:function(ajaxrequest) {
            //isDeleted = false;
        },
        success:function(resultData) {
            responseText = resultData;
        },
        complete: function (XMLHttpRequest, textStatus) {
            if (textStatus == "success" && responseText!=null) {
                txt = responseText;
                if(txt.indexOf(attachID) == -1) {
                    //isDeleted
                    clearAttachID(attachID);
                }else {
                   //not Deleted
                   var errorbox=$('#attacherror_box');
                   showBox('attacherror_box');
                   errorbox.html('ERROR:: Unable to delete your attachment.');
                }    
            }
        }
    });
}
function clearAttachID(attachID) {
     var fileCnt=0;
     for (var i=0;i<document.inquiry.length;i++) {
        var e = document.inquiry.elements[i];
        if (e.name=='Attachment_ID' && e.value==attachID) {
            document.inquiry.elements[i+1].value="";
            document.inquiry.elements[i+2].value="";
            document.inquiry.elements[i+3].value="";
            e.value="";
        }
        if (e.name=='Attachment_ID' && e.value!="")
            fileCnt++;
    }
    //hide that file
    hideBox(attachID);

    //hide the grey box if last item
    if (fileCnt==0)
        hideBox('files');
}
function getLastIDAdded(lastadded){
 var fileVal=lastadded.split('|');
      //SUCCESS|Id|FileName|MimeType|Size
      var fileArr=new Array(4); 
      for (var i=1; i<fileVal.length; i++) {
          fileArr[i]=fileVal[i]
      }
      var lastAddedID=fileArr[1];
      return lastAddedID;
}
/*No need for now
function collectIDcheck(lastadded) {
      var fileVal=lastadded.split('|');
      //SUCCESS|Id|FileName|MimeType|Size
      var fileArr=new Array(4); 
      for (var i=1; i<fileVal.length; i++) {
          fileArr[i]=fileVal[i]
      }
      var lastAddedID=fileArr[1];
      
    var list='';
    for (var i=0;i<document.inquiry.length;i++) {
	var e = document.inquiry.elements[i];
        if (e.name=='Attachment_ID' && e.type=='checkbox' && e.checked==true) 
            list+=e.value+'|';
    }
    return list+lastAddedID;
}
function checkIDchecked(list) {
    for (var i=0;i<document.inquiry.length;i++) {
	var e = document.inquiry.elements[i];
        if (e.name=='Attachment_ID' && e.type=='checkbox') {
            if (e.value!=0 && list.indexOf(e.value)>-1)
                e.checked=true;
            else
                e.checked=false;
        }
    }
}
function grayFile(field, attachID) {
    check=field.checked;
    id=attachID;
    color=(check? '#000000' : '#999999');
    if (document.getElementById) {
        document.getElementById(id).style.color = color;
    } else if (document.layers) {
        document[id].color = color;
    }
    if (check) { //for action handling
        field.checked=true;
        field.value=attachID;
    } else {
        field.checked=false;
        field.value=0;
    }    
}
*/
function fileStatus(file,icon) {
   var fileupload='<img src=\''+icon+'\' width=9 height=14 align=absmiddle> '
       +'<span class=black_text>'+file + ' (Uploading ...)</span>';
   return fileupload;
}
function trackAttachment(errCode, trackType, WAGIF, lastID) {
    tractID='trackAttachment';
    tracking= WAGIF +'?formNm='+trackType;
    err_count=parseInt(document.inquiry.att_err_cnt.value);
    if (errCode==0)
        tracking+='&err=0&id='+lastID;
    else {
        err_count++;
        tracking+='&err='+err_count+'attachment';
        if (errCode=='MAX')
            tracking+='&filesize=1N&filetype=0&filevirus=0&othererr=0';
        else if (errCode=='FNA')
            tracking+='&filesize=0&filetype=1N&filevirus=0&othererr=0';
        else if (errCode=='VIR')
            tracking+='&filesize=0&filetype=0&filevirus=1N&othererr=0';
        else
            tracking+='&filesize=0&filetype=0&filevirus=0&othererr=1N';    
     }  
    document.inquiry.att_err_cnt.value=err_count; //save it
    if (document.getElementById) {
        document.getElementById(tractID).src= tracking;
    } else if (document.layers) {
        document[tractID].src = tracking;
	}
}
/*--end Added for new attach flow */
/* 1supp inqall redirect */
function inqAllSupplierCategory(selectObj,baseURL) {
	if (selectObj.selectedIndex > 0) {
		window.location.href = baseURL + "&point_id=" + selectObj[selectObj.selectedIndex].value;
	}
}
/* callout bubble for inqall box */
var tipwidth='150px' //default tooltip width
var tipbgcolor='white'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="5px" //horizontal offset of tooltip from anchor link
var horizontal_offset="50px" //horizontal offset of tooltip from anchor link
var ie4=document.all;
var ns6=document.getElementById&&!document.all;
if(ie4||ns6){document.write("<div id=\"fixedtipdiv\" style=\"visibility:hidden;width:"+tipwidth+";background-color:"+tipbgcolor+"\" ></div>");}
function getposOffset(_1,_2){var _3=(_2=="left")?_1.offsetLeft:_1.offsetTop;var _4=_1.offsetParent;while(_4!=null){_3=(_2=="left")?_3+_4.offsetLeft:_3+_4.offsetTop;_4=_4.offsetParent;}return _3;};
function showhide(_5,e,_6,_7,_8){if(ie4||ns6){dropmenuobj.style.left=dropmenuobj.style.top=-500;}if(_8!=""){dropmenuobj.widthobj=dropmenuobj.style;dropmenuobj.widthobj.width=_8;}if(e.type=="click"&&_5.visibility==_7||e.type=="mouseover"){_5.visibility=_6;}else{if(e.type=="click"){_5.visibility=_7;}}};
function iecompattest(){return (document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;};
function clearbrowseredge(_9,_a){var _b=(_a=="rightedge")?parseInt(horizontal_offset)*-1:parseInt(vertical_offset)*-1;if(_a=="rightedge"){var _c=ie4&&!window.opera?iecompattest().scrollLeft+iecompattest().clientWidth-15:window.pageXOffset+window.innerWidth-15;dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;if(_c-dropmenuobj.x<dropmenuobj.contentmeasure){_b=dropmenuobj.contentmeasure-_9.offsetWidth;}}else{var _c=ie4&&!window.opera?iecompattest().scrollTop+iecompattest().clientHeight-15:window.pageYOffset+window.innerHeight-18;dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;if(_c-dropmenuobj.y<dropmenuobj.contentmeasure){_b=dropmenuobj.contentmeasure+_9.offsetHeight;}}return _b;};
function fixedtooltip(_d,_e,e,_f){if(window.event){event.cancelBubble=true;}else{if(e.stopPropagation){e.stopPropagation();}}clearhidetip();dropmenuobj=document.getElementById?document.getElementById("fixedtipdiv"):fixedtipdiv;dropmenuobj.innerHTML=_d;if(ie4||ns6){showhide(dropmenuobj.style,e,"visible","hidden",_f);dropmenuobj.x=getposOffset(_e,"left");dropmenuobj.y=getposOffset(_e,"top");dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(_e,"rightedge")+"px";dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(_e,"bottomedge")+_e.offsetHeight+"px";}};
function hidetip(e){if(typeof dropmenuobj!="undefined"){if(ie4||ns6){dropmenuobj.style.visibility="hidden";}}};
function delayhidetip(){if(ie4||ns6){delayhide=setTimeout("hidetip()",disappeardelay);}};
function clearhidetip(){if(typeof delayhide!="undefined"){clearTimeout(delayhide);}};
/*
 * JQuery Form Plugin
 */
(function($){$.fn.ajaxSubmit=function(_1){if(!this.length){_2("ajaxSubmit: skipping submit process - no element selected");return this;}if(typeof _1=="function"){_1={success:_1};}var _3=$.trim(this.attr("action"));if(_3){_3=(_3.match(/^([^#]+)/)||[])[1];}_3=_3||window.location.href||"";_1=$.extend({url:_3,type:this.attr("method")||"GET"},_1||{});var _4={};this.trigger("form-pre-serialize",[this,_1,_4]);if(_4.veto){_2("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this;}if(_1.beforeSerialize&&_1.beforeSerialize(this,_1)===false){_2("ajaxSubmit: submit aborted via beforeSerialize callback");return this;}var a=this.formToArray(_1.semantic);if(_1.data){_1.extraData=_1.data;for(var n in _1.data){if(_1.data[n] instanceof Array){for(var k in _1.data[n]){a.push({name:n,value:_1.data[n][k]});}}else{a.push({name:n,value:_1.data[n]});}}}if(_1.beforeSubmit&&_1.beforeSubmit(a,this,_1)===false){_2("ajaxSubmit: submit aborted via beforeSubmit callback");return this;}this.trigger("form-submit-validate",[a,this,_1,_4]);if(_4.veto){_2("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this;}var q=$.param(a);if(_1.type.toUpperCase()=="GET"){_1.url+=(_1.url.indexOf("?")>=0?"&":"?")+q;_1.data=null;}else{_1.data=q;}var _5=this,_6=[];if(_1.resetForm){_6.push(function(){_5.resetForm();});}if(_1.clearForm){_6.push(function(){_5.clearForm();});}if(!_1.dataType&&_1.target){var _7=_1.success||function(){};_6.push(function(_8){$(_1.target).html(_8).each(_7,arguments);});}else{if(_1.success){_6.push(_1.success);}}_1.success=function(_9,_a){for(var i=0,_b=_6.length;i<_b;i++){_6[i].apply(_1,[_9,_a,_5]);}};var _c=$("input:file",this).fieldValue();var _d=false;for(var j=0;j<_c.length;j++){if(_c[j]){_d=true;}}var _e=false;if(_1.iframe||_d||_e){if(_1.closeKeepAlive){$.get(_1.closeKeepAlive,_f);}else{_f();}}else{$.ajax(_1);}this.trigger("form-submit-notify",[this,_1]);return this;function _f(){var _10=_5[0];if($(":input[name=submit]",_10).length){alert("Error: Form elements must not be named \"submit\".");return;}var _11=$.extend({},$.ajaxSettings,_1);var s=$.extend(true,{},$.extend(true,{},$.ajaxSettings),_11);var id="jqFormIO"+(new Date().getTime());var $io=$("<iframe id=\""+id+"\" name=\""+id+"\" src=\"about:blank\" />");var io=$io[0];$io.css({position:"absolute",top:"-1000px",left:"-1000px"});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr("src","about:blank");}};var g=_11.global;if(g&&!$.active++){$.event.trigger("ajaxStart");}if(g){$.event.trigger("ajaxSend",[xhr,_11]);}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&$.active--;return;}if(xhr.aborted){return;}var _12=0;var _13=0;var sub=_10.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){_1.extraData=_1.extraData||{};_1.extraData[n]=sub.value;if(sub.type=="image"){_1.extraData[name+".x"]=_10.clk_x;_1.extraData[name+".y"]=_10.clk_y;}}}setTimeout(function(){var t=_5.attr("target"),a=_5.attr("action");_10.setAttribute("target",id);if(_10.getAttribute("method")!="POST"){_10.setAttribute("method","POST");}if(_10.getAttribute("action")!=_11.url){_10.setAttribute("action",_11.url);}if(!_1.skipEncodingOverride){_5.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});}if(_11.timeout){setTimeout(function(){_13=true;cb();},_11.timeout);}var _14=[];try{if(_1.extraData){for(var n in _1.extraData){_14.push($("<input type=\"hidden\" name=\""+n+"\" value=\""+_1.extraData[n]+"\" />").appendTo(_10)[0]);}}$io.appendTo("body");io.attachEvent?io.attachEvent("onload",cb):io.addEventListener("load",cb,false);_10.submit();}finally{_10.setAttribute("action",a);t?_10.setAttribute("target",t):_5.removeAttr("target");$(_14).remove();}},10);var _15=50;function cb(){if(_12++){return;}io.detachEvent?io.detachEvent("onload",cb):io.removeEventListener("load",cb,false);var ok=true;try{if(_13){throw "timeout";}var _16,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;var _17=_11.dataType=="xml"||doc.XMLDocument||$.isXMLDoc(doc);_2("isXml="+_17);if(!_17&&(doc.body==null||doc.body.innerHTML=="")){if(--_15){_12=0;setTimeout(cb,100);return;}_2("Could not access iframe DOM after 50 tries.");return;}xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(_18){var _19={"content-type":_11.dataType};return _19[_18];};if(_11.dataType=="json"||_11.dataType=="script"){var ta=doc.getElementsByTagName("textarea")[0];if(ta){xhr.responseText=ta.value;}else{var pre=doc.getElementsByTagName("pre")[0];if(pre){xhr.responseText=pre.innerHTML;}}}else{if(_11.dataType=="xml"&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=_1a(xhr.responseText);}}_16=$.httpData(xhr,_11.dataType);}catch(e){ok=false;$.handleError(_11,xhr,"error",e);}if(ok){_11.success(_16,"success");if(g){$.event.trigger("ajaxSuccess",[xhr,_11]);}}if(g){$.event.trigger("ajaxComplete",[xhr,_11]);}if(g&&!--$.active){$.event.trigger("ajaxStop");}if(_11.complete){_11.complete(xhr,ok?"success":"error");}setTimeout(function(){$io.remove();xhr.responseXML=null;},100);};function _1a(s,doc){if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(s);}else{doc=(new DOMParser()).parseFromString(s,"text/xml");}return (doc&&doc.documentElement&&doc.documentElement.tagName!="parsererror")?doc:null;};};};$.fn.ajaxForm=function(_1b){return this.ajaxFormUnbind().bind("submit.form-plugin",function(){$(this).ajaxSubmit(_1b);return false;}).bind("click.form-plugin",function(e){var $el=$(e.target);if(!($el.is(":submit,input:image"))){return;}var _1c=this;_1c.clk=e.target;if(e.target.type=="image"){if(e.offsetX!=undefined){_1c.clk_x=e.offsetX;_1c.clk_y=e.offsetY;}else{if(typeof $.fn.offset=="function"){var _1d=$el.offset();_1c.clk_x=e.pageX-_1d.left;_1c.clk_y=e.pageY-_1d.top;}else{_1c.clk_x=e.pageX-e.target.offsetLeft;_1c.clk_y=e.pageY-e.target.offsetTop;}}}setTimeout(function(){_1c.clk=_1c.clk_x=_1c.clk_y=null;},10);});};$.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin");};$.fn.formToArray=function(_1e){var a=[];if(this.length==0){return a;}var _1f=this[0];var els=_1e?_1f.getElementsByTagName("*"):_1f.elements;if(!els){return a;}for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n){continue;}if(_1e&&_1f.clk&&el.type=="image"){if(!el.disabled&&_1f.clk==el){a.push({name:n,value:$(el).val()});a.push({name:n+".x",value:_1f.clk_x},{name:n+".y",value:_1f.clk_y});}continue;}var v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(var j=0,_20=v.length;j<_20;j++){a.push({name:n,value:v[j]});}}else{if(v!==null&&typeof v!="undefined"){a.push({name:n,value:v});}}}if(!_1e&&_1f.clk){var _21=$(_1f.clk),_22=_21[0],n=_22.name;if(n&&!_22.disabled&&_22.type=="image"){a.push({name:n,value:_21.val()});a.push({name:n+".x",value:_1f.clk_x},{name:n+".y",value:_1f.clk_y});}}return a;};$.fn.formSerialize=function(_23){return $.param(this.formToArray(_23));};$.fn.fieldSerialize=function(_24){var a=[];this.each(function(){var n=this.name;if(!n){return;}var v=$.fieldValue(this,_24);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++){a.push({name:n,value:v[i]});}}else{if(v!==null&&typeof v!="undefined"){a.push({name:this.name,value:v});}}});return $.param(a);};$.fn.fieldValue=function(_25){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,_25);if(v===null||typeof v=="undefined"||(v.constructor==Array&&!v.length)){continue;}v.constructor==Array?$.merge(val,v):val.push(v);}return val;};$.fieldValue=function(el,_26){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof _26=="undefined"){_26=true;}if(_26&&(!n||el.disabled||t=="reset"||t=="button"||(t=="checkbox"||t=="radio")&&!el.checked||(t=="submit"||t=="image")&&el.form&&el.form.clk!=el||tag=="select"&&el.selectedIndex==-1)){return null;}if(tag=="select"){var _27=el.selectedIndex;if(_27<0){return null;}var a=[],ops=el.options;var one=(t=="select-one");var max=(one?_27+1:ops.length);for(var i=(one?_27:0);i<max;i++){var op=ops[i];if(op.selected){var v=op.value;if(!v){v=(op.attributes&&op.attributes["value"]&&!(op.attributes["value"].specified))?op.text:op.value;}if(one){return v;}a.push(v);}}return a;}return el.value;};$.fn.clearForm=function(){return this.each(function(){$("input,select,textarea",this).clearFields();});};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=="text"||t=="password"||tag=="textarea"){this.value="";}else{if(t=="checkbox"||t=="radio"){this.checked=false;}else{if(tag=="select"){this.selectedIndex=-1;}}}});};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset();}});};$.fn.enable=function(b){if(b==undefined){b=true;}return this.each(function(){this.disabled=!b;});};$.fn.selected=function(_28){if(_28==undefined){_28=true;}return this.each(function(){var t=this.type;if(t=="checkbox"||t=="radio"){this.checked=_28;}else{if(this.tagName.toLowerCase()=="option"){var _29=$(this).parent("select");if(_28&&_29[0]&&_29[0].type=="select-one"){_29.find("option").selected(false);}this.selected=_28;}}});};function _2(){if($.fn.ajaxSubmit.debug&&window.console&&window.console.log){window.console.log("[jquery.form] "+Array.prototype.join.call(arguments,""));}};})(jQuery);
/**
 * Ajax upload
 * Project page - http://valums.com/ajax-upload/
 * Copyright (c) 2008 Andris Valums, http://valums.com
 * Licensed under the MIT license (http://valums.com/mit-license/)
 * Version 3.5 (23.06.2009)
 */
(function(){
var d = document, w = window;
/**
 * Get element by id
 */	
function get(element){
	if (typeof element == "string")
		element = d.getElementById(element);
	return element;
}
/**
 * Attaches event to a dom element
 */
function addEvent(el, type, fn){
	if (w.addEventListener){
		el.addEventListener(type, fn, false);
	} else if (w.attachEvent){
		var f = function(){
		  fn.call(el, w.event);
		};			
		el.attachEvent('on' + type, f)
	}
}
/**
 * Creates and returns element from html chunk
 */
var toElement = function(){
	var div = d.createElement('div');
	return function(html){
		div.innerHTML = html;
		var el = div.childNodes[0];
		div.removeChild(el);
		return el;
	}
}();
function hasClass(ele,cls){
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
	ele.className=ele.className.replace(reg,' ');
}
// getOffset function copied from jQuery lib (http://jquery.com/)
if (document.documentElement["getBoundingClientRect"]){
	// Get Offset using getBoundingClientRect
	// http://ejohn.org/blog/getboundingclientrect-is-awesome/
	var getOffset = function(el){
		var box = el.getBoundingClientRect(),
		doc = el.ownerDocument,
		body = doc.body,
		docElem = doc.documentElement,
		
		// for ie 
		clientTop = docElem.clientTop || body.clientTop || 0,
		clientLeft = docElem.clientLeft || body.clientLeft || 0,
		
		// In Internet Explorer 7 getBoundingClientRect property is treated as physical,
		// while others are logical. Make all logical, like in IE8.
		
		
		zoom = 1;
		if (body.getBoundingClientRect) {
			var bound = body.getBoundingClientRect();
			zoom = (bound.right - bound.left)/body.clientWidth;
		}
		if (zoom > 1){
			clientTop = 0;
			clientLeft = 0;
		}
		var top = box.top/zoom + (window.pageYOffset || docElem && docElem.scrollTop/zoom || body.scrollTop/zoom) - clientTop,
		left = box.left/zoom + (window.pageXOffset|| docElem && docElem.scrollLeft/zoom || body.scrollLeft/zoom) - clientLeft;
				
		return {
			top: top,
			left: left
		};
	}
} else {
	// Get offset adding all offsets 
	var getOffset = function(el){
		if (w.jQuery){
			return jQuery(el).offset();
		}		
			
		var top = 0, left = 0;
		do {
			top += el.offsetTop || 0;
			left += el.offsetLeft || 0;
		}
		while (el = el.offsetParent);
		
		return {
			left: left,
			top: top
		};
	}
}
function getBox(el){
	var left, right, top, bottom;	
	var offset = getOffset(el);
	left = offset.left;
	top = offset.top;
						
	right = left + el.offsetWidth;
	bottom = top + el.offsetHeight;		
		
	return {
		left: left,
		right: right,
		top: top,
		bottom: bottom
	};
}
/**
 * Crossbrowser mouse coordinates
 */
function getMouseCoords(e){		
	// pageX/Y is not supported in IE
	// http://www.quirksmode.org/dom/w3c_cssom.html			
	if (!e.pageX && e.clientX){
		// In Internet Explorer 7 some properties (mouse coordinates) are treated as physical,
		// while others are logical (offset).
		var zoom = 1;	
		var body = document.body;
		
		if (body.getBoundingClientRect) {
			var bound = body.getBoundingClientRect();
			zoom = (bound.right - bound.left)/body.clientWidth;
		}

		return {
			x: e.clientX / zoom + d.body.scrollLeft + d.documentElement.scrollLeft,
			y: e.clientY / zoom + d.body.scrollTop + d.documentElement.scrollTop
		};
	}
	
	return {
		x: e.pageX,
		y: e.pageY
	};		

}
/**
 * Function generates unique id
 */		
var getUID = function(){
	var id = 0;
	return function(){
		return 'ValumsAjaxUpload' + id++;
	}
}();
function fileFromPath(file){
	return file.replace(/.*(\/|\\)/, "");			
}
function getExt(file){
	return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
}			
// Please use AjaxUpload , Ajax_upload will be removed in the next version
Ajax_upload = AjaxUpload = function(button, options){
	if (button.jquery){
		// jquery object was passed
		button = button[0];
	} else if (typeof button == "string" && /^#.*/.test(button)){					
		button = button.slice(1);				
	}
	button = get(button);	
	
	this._input = null;
	this._button = button;
	this._disabled = false;
	this._submitting = false;
	// Variable changes to true if the button was clicked
	// 3 seconds ago (requred to fix Safari on Mac error)
	this._justClicked = false;
	this._parentDialog = d.body;
	if (window.jQuery && jQuery.ui && jQuery.ui.dialog){
		var parentDialog = jQuery(this._button).parents('.ui-dialog');
		if (parentDialog.length){
			this._parentDialog = parentDialog[0];
		}
	}			
	this._settings = {
		// Location of the server-side upload script
		action: 'upload.php',			
		// File upload name
		name: 'userfile',
		// Additional data to send
		data: {},
		// Submit file as soon as it's selected
		autoSubmit: true,
		// The type of data that you're expecting back from the server.
		// Html and xml are detected automatically.
		// Only useful when you are using json data as a response.
		// Set to "json" in that case. 
		responseType: false,
		// When user selects a file, useful with autoSubmit disabled			
		onChange: function(file, extension){},					
		// Callback to fire before file is uploaded
		// You can return false to cancel upload
		onSubmit: function(file, extension){},
		// Fired when file upload is completed
		// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
		onComplete: function(file, response) {}
	};
	// Merge the users options with our defaults
	for (var i in options) {
		this._settings[i] = options[i];
	}
	this._createInput();
	this._rerouteClicks();
}
// assigning methods to our class
AjaxUpload.prototype = {
	setData : function(data){
		this._settings.data = data;
	},
	disable : function(){
		this._disabled = true;
	},
	enable : function(){
		this._disabled = false;
	},
	// removes ajaxupload
	destroy : function(){
		if(this._input){
			if(this._input.parentNode){
				this._input.parentNode.removeChild(this._input);
			}
			this._input = null;
		}
	},				
	/**
	 * Creates invisible file input above the button 
	 */
	_createInput : function(){
		var self = this;
		var input = d.createElement("input");
		input.setAttribute('type', 'file');
		input.setAttribute('name', this._settings.name);
		var styles = {
			'position' : 'absolute'
			,'margin': '-5px 0 0 -175px'
			,'padding': 0
			,'width': '220px'
			,'height': '30px'
			,'fontSize': '14px'								
			,'opacity': 0
			,'cursor': 'pointer'
			,'display' : 'none'
			,'zIndex' :  2147483583 //Max zIndex supported by Opera 9.0-9.2x 
			// Strange, I expected 2147483647					
		};
		for (var i in styles){
			input.style[i] = styles[i];
		}
		// Make sure that element opacity exists
		// (IE uses filter instead)
		if ( ! (input.style.opacity === "0")){
			input.style.filter = "alpha(opacity=0)";
		}
		this._parentDialog.appendChild(input);
		addEvent(input, 'change', function(){
			// get filename from input
			var file = fileFromPath(this.value);	
			if(self._settings.onChange.call(self, file, getExt(file)) == false ){
				return;				
			}														
			// Submit form when value is changed
			if (self._settings.autoSubmit){
				self.submit();						
			}						
		});
		// Fixing problem with Safari
		// The problem is that if you leave input before the file select dialog opens
		// it does not upload the file.
		// As dialog opens slowly (it is a sheet dialog which takes some time to open)
		// there is some time while you can leave the button.
		// So we should not change display to none immediately
		addEvent(input, 'click', function(){
			self.justClicked = true;
			setTimeout(function(){
				// we will wait 3 seconds for dialog to open
				self.justClicked = false;
			}, 3000);			
		});		
		
		this._input = input;
	},
	_rerouteClicks : function (){
		var self = this;
		// IE displays 'access denied' error when using this method
		// other browsers just ignore click()
		// addEvent(this._button, 'click', function(e){
		//   self._input.click();
		// });
		var box, dialogOffset = {top:0, left:0}, over = false;							
		addEvent(self._button, 'mouseover', function(e){
			if (!self._input || over) return;
			over = true;
			box = getBox(self._button);
					
			if (self._parentDialog != d.body){
				dialogOffset = getOffset(self._parentDialog);
			}	
		});
		
	
		// we can't use mouseout on the button,
		// because invisible input is over it
		addEvent(document, 'mousemove', function(e){
			var input = self._input;			
			if (!input || !over) return;
			
			if (self._disabled){
				removeClass(self._button, 'hover');
				input.style.display = 'none';
				return;
			}	
										
			var c = getMouseCoords(e);

			if ((c.x >= box.left) && (c.x <= box.right) && 
			(c.y >= box.top) && (c.y <= box.bottom)){			
				input.style.top = c.y - dialogOffset.top + 'px';
				input.style.left = c.x - dialogOffset.left + 'px';
				input.style.display = 'block';
				addClass(self._button, 'hover');				
			} else {		
				// mouse left the button
				over = false;
				if (!self.justClicked){
					input.style.display = 'none';
				}
				removeClass(self._button, 'hover');
			}			
		});			
			
	},
	/**
	 * Creates iframe with unique name
	 */
	_createIframe : function(){
		// unique name
		// We cannot use getTime, because it sometimes return
		// same value in safari :(
		var id = getUID();
		
		// Remove ie6 "This page contains both secure and nonsecure items" prompt 
		// http://tinyurl.com/77w9wh
		var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
		iframe.id = id;
		iframe.style.display = 'none';
		d.body.appendChild(iframe);			
		return iframe;						
	},
	/**
	 * Upload file without refreshing the page
	 */
	submit : function(){
		var self = this, settings = this._settings;	
					
		if (this._input.value === ''){
			// there is no file
			return;
		}
										
		// get filename from input
		var file = fileFromPath(this._input.value);			

		// execute user event
		if (! (settings.onSubmit.call(this, file, getExt(file)) == false)) {
			// Create new iframe for this submission
			var iframe = this._createIframe();
			
			// Do not submit if user function returns false										
			var form = this._createForm(iframe);
			form.appendChild(this._input);
			
			form.submit();
			
			d.body.removeChild(form);				
			form = null;
			this._input = null;
			
			// create new input
			this._createInput();
			
			var toDeleteFlag = false;
			
			addEvent(iframe, 'load', function(e){
					
				if (// For Safari
					iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" ||
					// For FF, IE
					iframe.src == "javascript:'<html></html>';"){						
					
					// First time around, do not delete.
					if( toDeleteFlag ){
						// Fix busy state in FF3
						setTimeout( function() {
							d.body.removeChild(iframe);
						}, 0);
					}
					return;
				}				
				
				var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;

				// fixing Opera 9.26
				if (doc.readyState && doc.readyState != 'complete'){
					// Opera fires load event multiple times
					// Even when the DOM is not ready yet
					// this fix should not affect other browsers
					return;
				}
				
				// fixing Opera 9.64
				if (doc.body && doc.body.innerHTML == "false"){
					// In Opera 9.64 event was fired second time
					// when body.innerHTML changed from false 
					// to server response approx. after 1 sec
					return;				
				}
				
				var response;
									
				if (doc.XMLDocument){
					// response is a xml document IE property
					response = doc.XMLDocument;
				} else if (doc.body){
					// response is html document or plain text
					response = doc.body.innerHTML;
					if (settings.responseType && settings.responseType.toLowerCase() == 'json'){
						// If the document was sent as 'application/javascript' or
						// 'text/javascript', then the browser wraps the text in a <pre>
						// tag and performs html encoding on the contents.  In this case,
						// we need to pull the original text content from the text node's
						// nodeValue property to retrieve the unmangled content.
						// Note that IE6 only understands text/html
						if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){
							response = doc.body.firstChild.firstChild.nodeValue;
						}
						if (response) {
							response = window["eval"]("(" + response + ")");
						} else {
							response = {};
						}
					}
				} else {
					// response is a xml document
					var response = doc;
				}
																			
				settings.onComplete.call(self, file, response);
						
				// Reload blank page, so that reloading main page
				// does not re-submit the post. Also, remember to
				// delete the frame
				toDeleteFlag = true;
				
				// Fix IE mixed content issue
				iframe.src = "javascript:'<html></html>';";		 								
			});
	
		} else {
			// clear input to allow user to select same file
			// Doesn't work in IE6
			// this._input.value = '';
			d.body.removeChild(this._input);				
			this._input = null;
			
			// create new input
			this._createInput();						
		}
	},		
	/**
	 * Creates form, that will be submitted to iframe
	 */
	_createForm : function(iframe){
		var settings = this._settings;
		
		// method, enctype must be specified here
		// because changing this attr on the fly is not allowed in IE 6/7		
		var form = toElement('<form method="post" enctype="multipart/form-data"></form>');
		form.style.display = 'none';
		form.action = settings.action;
		form.target = iframe.name;
		d.body.appendChild(form);
		
		// Create hidden input element for each data key
		for (var prop in settings.data){
			var el = d.createElement("input");
			el.type = 'hidden';
			el.name = prop;
			el.value = settings.data[prop];
			form.appendChild(el);
		}			
		return form;
	}	
};
})();
/** FROM INQUIRYSSOVALIDATION **/
function checkValidUID(formObj,takenDivID,invalidDivID,tdID,bID,srcPink,srcBlue) {
	var retVal = true;
	if (formObj.value.length > 0) {
		hideBox('HttpErrorInquiryUsername');
		hideBox(invalidDivID);
		if (hasSpecialChars(formObj.value)) {
			hideBox(takenDivID);
			showBox(invalidDivID);
			//formObj.value = '';
			retVal = false;
		} else {
			var responseText = null;
			var myurl = '/gsol/gsol/en/clean/jsp/inquiry/LdapValidator.jsp?v=u&uid='+formObj.value;
			$.ajax({
				type:"GET", 
				url:myurl, 				
				dataType:"html", 
				cache: false,
				error:function(ajaxrequest) {
					showBox('HttpErrorInquiryUsername');
				},
				success:function(resultData) {
					responseText = resultData;
				},
				complete: function (XMLHttpRequest, textStatus) {
					if (textStatus == "success" && responseText!=null) {
				  		txt = responseText;
				  		if(txt.indexOf("true") > -1){
							showBox(takenDivID);
							retVal = false;
							checkFieldIsNotInError(retVal,true,tdID,bID,srcPink,srcBlue);
							//formObj.value = '';
				  		}else{
							hideBox(takenDivID);
				  		}				
					}
				}
			});
		}
	} else {
		hideBox('HttpErrorInquiryUsername');
		hideBox(takenDivID);
		hideBox(invalidDivID);
	}
	return retVal;
}
var validationInProgress = false;
function validateLoginCombo() {
	validationInProgress = true;
	hideBox('MustMatchLoginUsername');
	hideBox('MustExistLoginUsername');
	hideBox('HttpErrorLoginComboCheck');
	var receivedStr = null;
	var myurl = '/gsol/gsol/en/clean/jsp/inquiry/LdapValidator.jsp?v=up&uid='+ escape(document.inquiry.inquiry_login_username.value) + '&pwd=' + escape(document.inquiry.inquiry_login_password.value);
	$.ajax({
		type:"GET", 
		url:myurl, 				
		dataType:"html", 
		cache: false,
		error:function(ajaxrequest) {
			showBox('HttpErrorLoginComboCheck');
    	    document.inquiry.uid.value = '';
		},
		success:function(resultData) {
			receivedStr = resultData;
		},
		complete: function (XMLHttpRequest, textStatus) {
			if (textStatus == "success" && receivedStr!=null) {
		  		txt = receivedStr;
				var retVal = true;
		  		if(txt.indexOf("NOMATCH") > -1){
		  		  showBox('MustMatchLoginUsername');
		  		  document.inquiry.uid.value = '';
				  retVal = false;
				} else if (txt.indexOf("NOEXIST") > -1) {
		  		  showBox('MustExistLoginUsername');
		  		  document.inquiry.uid.value = '';
				  retVal = false;
		  		}else if (txt.indexOf("400") > -1) {
		  		  document.inquiry.uid.value = txt;
		  		} else {
				  showBox('HttpErrorLoginComboCheck');
		  		  document.inquiry.uid.value = '';
				  retVal = false;
				}
				checkFieldIsNotInError(retVal,true,'td_login_name','b_login_name',pinkBGImgPath,blueBGImgPath);
				checkFieldIsNotInError(retVal,true,'td_login_password','b_login_password',pinkBGImgPath,blueBGImgPath);
			}
			validationInProgress = false;
		}
	})	
}

function saveThisForm(myAttachURL) {
	var rfiLoginURL = null;
	convertFieldsToSafeText();
	$.ajax({
		type:"POST", 
		url:myAttachURL, 				
		data:$("#myInquiryForm :not([rel='userdetail'])").fieldSerialize(),
		dataType:"html", 
		cache: false,
		error:function(ajaxrequest) {
			alert("ERROR :: Could not save the inquiry form!");
		},
		success:function(resultData) {
			rfiLoginURL = resultData;
		},
		complete: function (XMLHttpRequest, textStatus) {
			if (textStatus == "success" && rfiLoginURL!=null) {
				dhtmlmodal.open('LoginBox', 'iframe', rfiLoginURL, 'Login', 'width=400px,height=295px,center=1,resize=0,scrolling=0');
			}
		}
	})
}
var emailValidationInProgress = false;
function checkEmailExists(formObj,origEmailVal,takenDivID,takenLiteDivID,tipDivID,invalidDivID,tdID,bID,srcPink,srcBlue) {
	var retVal = true;
	if (formObj.value.length > 0 && Trim(formObj.value) != Trim(origEmailVal)) {
		if (checkForEmailError(formObj.value)>0) {
			hideBox(takenDivID);
			retVal = false;
		} else {
			emailValidationInProgress = true;
			hideBox(invalidDivID);
			var responseText = null;
			var myurl = '/gsol/gsol/en/clean/jsp/inquiry/LdapValidator.jsp?v=m-lite&mail='+formObj.value; //check for reg and palite
			$.ajax({
				type:"GET", 
				url:myurl, 				
				dataType:"html", 
				cache: false,
				error:function(ajaxrequest) {
					showBox('HttpErrorInquiryUsername');
				},
				success:function(resultData) {
					responseText = resultData;
				},
				complete: function (XMLHttpRequest, textStatus) {
					if (textStatus == "success" && responseText!=null) {
						txt = responseText;
						if(txt.indexOf("true") > -1){
							try {
								formObj.focus();
							} catch (err) {
								//do nothing
							}
							retVal = false;
							if(txt.indexOf("palite") > -1) {
								showBox(takenLiteDivID);
								showBox(tipDivID);
								hideBox(takenDivID);
								dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-OrgEmail', 'WT.error_str','LiteEmailErr','WT.rfi_status', inqFlowPath);
							} else {
							showBox(takenDivID);
							showBox(tipDivID);
								hideBox(takenLiteDivID);
								dcsMultiTrack('DCS.dcsuri', '/RFI-Err.htm', 'WT.ti', 'RFI Err', 'WT.si_n', 'RFI', 'WT.si_p', 'RFI-OrgEmail', 'WT.error_str','RegEmailErr','WT.rfi_status', inqFlowPath);
							}
							//if exists, hide others as well
							hideBox('ReqdEmail');
							hideBox('InvalidEmail1');
							hideBox('InvalidEmail2');
							document.getElementById(bID).style.color = "#CC0000";
							//checkFieldIsNotInError(retVal,true,tdID,bID,srcPink,srcBlue);
						}else{
							hideBox(takenDivID);
							hideBox(takenLiteDivID);
							hideBox(tipDivID);
							document.getElementById(bID).style.color = "#000000";
						}				
					}
					emailValidationInProgress = false;
				}
			});
		}
	} else {
		hideBox(takenDivID);
		hideBox(takenLiteDivID);
		hideBox(tipDivID);
	}
	return retVal;
}
/* FROM FORMCHEK */
var whitespace=" \t\n\r";
function stripCharsInBag(s,_2){
	var i;
	var _4="";
	for(i=0;i<s.length;i++){
		var c=s.charAt(i);
		if(_2.indexOf(c)==-1){
			_4+=c;
		}
	}
	return _4;
}

function stripWhitespace(s){
	return stripCharsInBag(s,whitespace);
}

function trimEnds(_7){
	while(_7.substring(0,1)==" "){
		_7=_7.substring(1,_7.length);
	}
	while(_7.substring(_7.length-1,_7.length)==" "){
		_7=_7.substring(0,_7.length-1);
	}
	return _7;
}

function checkValidEmail(_8){
	var _9="This field must be a single, valid email address (like foo@bar.com). Please reenter it now.";
	var _a="Please enter only characters A-Z a-z 0-9 . @ _ - for E-mail Address.";
	dot=".";
	whitespace=" \t\n\r";
	var _b=true;
	var _c=trimEnds(_8.value);
	var _d=_c.indexOf("@");
	var _e=_c.indexOf(dot);
	var _f=_c.substring((_d+1),(_d+2)).indexOf(dot);
	var at4=_c.substring(0).indexOf(dot);
	var len=_c.length;
	var at5=_c.substring((len-1),len).indexOf(dot);
	var at6=_c.lastIndexOf("@");
	var at7=_c.substring((_d+1),len).indexOf(dot);
	var tld=_c.substring((_c.lastIndexOf(".")+1),len);
	var _16="com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|asia|cat|jobs|mobi|tel|travel";
	var _17=false;
	var _18=_c.substring(_d+1,len);
	if(_18.length>0){
		for(i=0;i<_18.length;i++){
			var c=_18.charAt(i);
			if(c==dot&&_18.charAt(i+1)==dot){
				_17=true;
			}
		}
	}
	var _1a=false;
	if((_16.indexOf(tld.toLowerCase())==-1)&&(tld.length!=2)){
		_1a=true;
	}
	var _1b=_c.match(/[^0-9a-zA-Z@._-]/);
	if(_d!=at6){
		alert(_9);
		_b=false;
	}else{
		if(_1b){
			alert(_a);
			_b=false;
		}else{
			if((_d<1)||(_f==0)||(at7==-1)||(at4==0)||(at5==0)||(_17)||(len-_e<2)||_1a){
				alert(_9);
				_b=false;
			}
		}
	}
	if(!_b){
		//_8.value="";
		//_8.select();
		//_8.focus();
	}else{
		_8.value=_c;
	}
	return _b;
}

function checkValidEmailNoPrompt(_1c){
	dot=".";
	whitespace=" \t\n\r";
	var _1d=true;
	var _1e=trimEnds(_1c);
	var at1=_1e.indexOf("@");
	var at2=_1e.indexOf(dot);
	var at3=_1e.substring((at1+1),(at1+2)).indexOf(dot);
	var at4=_1e.substring(0).indexOf(dot);
	var len=_1e.length;
	var at5=_1e.substring((len-1),len).indexOf(dot);
	var at6=_1e.lastIndexOf("@");
	var at7=_1e.substring((at1+1),len).indexOf(dot);
	var tld=_1e.substring((_1e.lastIndexOf(".")+1),len);
	var _28="com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|asia|cat|jobs|mobi|tel|travel";
	var _29=false;
	var _2a=_1e.substring(at1+1,len);
	if(_2a.length>0){
		for(i=0;i<_2a.length;i++){
			var c=_2a.charAt(i);
			if(c==dot&&_2a.charAt(i+1)==dot){
				_29=true;
			}
		}
	}
	var _2c=false;
	if((_28.indexOf(tld.toLowerCase())==-1)&&(tld.length!=2)){
		_2c=true;
	}
	var _2d=_1e.match(/[^0-9a-zA-Z@._-]/);
	if(at1!=at6){
		_1d=false;
	}else{
		if(_2d){
			_1d=false;
		}else{
			if((at1<1)||(at3==0)||(at7==-1)||(at4==0)||(at5==0)||(_29)||(len-at2<2)||_2c){
				_1d=false;
			}
		}
	}
	return _1d;
}

function checkForEmailError(_2e){
	dot=".";
	whitespace=" \t\n\r";
	var _2f=0;
	var _30=trimEnds(_2e);
	var at1=_30.indexOf("@");
	var at2=_30.indexOf(dot);
	var at3=_30.substring((at1+1),(at1+2)).indexOf(dot);
	var at4=_30.substring(0).indexOf(dot);
	var len=_30.length;
	var at5=_30.substring((len-1),len).indexOf(dot);
	var at6=_30.lastIndexOf("@");
	var at7=_30.substring((at1+1),len).indexOf(dot);
	var tld=_30.substring((_30.lastIndexOf(".")+1),len);
	var _3a="com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|asia|cat|jobs|mobi|tel|travel";
	var _3b=false;
	var _3c=_30.substring(at1+1,len);
	if(_3c.length>0){
		for(i=0;i<_3c.length;i++){
			var c=_3c.charAt(i);
			if(c==dot&&_3c.charAt(i+1)==dot){
				_3b=true;
			}
		}
	}
	var _3e=false;
	if((_3a.indexOf(tld.toLowerCase())==-1)&&(tld.length!=2)){
		_3e=true;
	}
	var _3f=_30.match(/[^0-9a-zA-Z@._-]/);
	if(_3f){
		_2f=2;
	}else{
		if(at1!=at6){
			_2f=1;
		}else{
			if((at1<1)||(at3==0)||(at7==-1)||(at4==0)||(at5==0)||(_3b)||(len-at2<2)||_3e){
				_2f=1;
			}
		}
	}
	return _2f;
}

function regpaliteUser(url,_41){
	regpaliteUserWithForm(url,_41,document.reqpalite);
}

function regpaliteUserWithForm(url,_43,_44){
	if(_43){
		var _45=stripWhitespace(_44.email.value);
		var _46=stripWhitespace(_44.code.value);
		if(_45==""){
			alert("Please enter e-mail");
			_44.email.focus();
		}else{
			if(_46==""){
				alert("Please Enter Code");
				_44.code.focus();
			}else{
				if(_45==""&&_46==""){
					_44.reset();
				}else{
					if(_45!=""&&_46!=""){
						if(checkValidEmailNoPrompt(_44.email.value)){
							_44.action=url;
							_44.submit();
						}
					}
				}
			}
		}
	}else{
		if(!_43){
			var _45=_44.email.value;
			if(_45==""){
				alert("Please enter e-mail");
				_44.email.focus();
			}else{
				if(_45=="Enter e-mail"){
					alert("Please enter e-mail");
					_44.email.value="";
					_44.email.focus();
				}else{
					if(_45==""){
						_44.reset();
					}else{
						if(_45!=""){
							var _47=checkForEmailError(_44.email.value);
							if(_47==1){
								alert("This field must be a valid e-mail address (like foo@bar.com). Please reenter it now.");
								_44.email.value="";
								_44.email.focus();
							}else{
								if(_47==2){
									alert("Please enter only characters A-Z a-z 0-9 . @ _ - for e-mail address.");
									_44.email.value="";
									_44.email.focus();
								}else{
									if(typeof (_44.searchQueryKeyword)=="undefined"){
										_44.action=url;
										_44.submit();
									}else{
										if(_44.searchQueryKeyword.value==""){
											alert("Please enter product keyword(s)");
											_44.searchQueryKeyword.focus();
										}else{
											_44.action=url;
											_44.submit();
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function write_blank(){
	write_blankForm(document.reqpalite);
}

function write_blankForm(_51){
	var _48=_51.email.value;
	if(_48=="Enter e-mail"||_48=="Enter e-mail address"){
		_51.email.value="";
	}
}

function keypresssubmit(url,_4a,evt){
	keypresssubmitWithForm(url,_4a,evt,document.reqpalite);
}

function keypresssubmitWithForm(url,_4d,evt,_4f){
	var _50=evt.keyCode;
	if(_50==13){
		regpaliteUserWithForm(url,_4d,_4f);
	}
}

function pax_write_blank(){
	var _48=document.pax_reqpalite.email.value;
	if(_48=="Enter e-mail"||_48=="Enter e-mail address" || _48 == "Enter your email here"){
		document.pax_reqpalite.email.value="";
	}
}
//add below for MR17360
/* Stack up window.onload events using this function from Simon Willison - http://www.sitepoint.com/blog-post-view.php?id=171578 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function destroycatfish(){
	var catfish = document.getElementById('catfish');
	document.body.removeChild(catfish); /* clip catfish off the tree */
	document.getElementsByTagName('html')[0].style.padding= '0'; /* reset the padding at the bottom */
	return false;
}

function closeme(){
	var closelink = document.getElementById('closeme');
	if(closelink != null)
		closelink.onclick = destroycatfish;

}
addLoadEvent(function() {
	closeme();
});

function SetPACookie(name,value){
	var argv=SetPACookie.arguments;
	var argc=SetPACookie.arguments.length
	var expires=(argc>2) ? argv[2] : null
	var path="/"
	var domain=".globalsources.com"
	var secure=(argc>5) ? argv[5] : false
	document.cookie=name + "=" +escape(value) + ((expires==null) ? "" :( ";expires=" + expires.toGMTString())) + ((path==null) ? "" :( ";path=" + path)) +	((domain==null) ? "" :( ";domain=" + domain)) +	((secure==true) ? "; secure " : "");
}

function GetPACookie(name){	
	var arg=name + "=" 
	var alen=arg.length
	var clen=document.cookie.length
	var i=0,prev=0;next=0;
	var retval=false;
	while(true)	{
		next=document.cookie.indexOf("; ", prev);
		if(next<=0){
			var chkval=document.cookie.substring(prev,clen);
			var eqpos=chkval.indexOf("=", 0);
			if(eqpos>0){
				if((chkval.substring(0,eqpos+1))==arg){
					retval=true;
					break;
				}	
			}	
			break;				
		}
		if(next>0){
			var chkval=document.cookie.substring(prev,next);
			var eqpos=chkval.indexOf("=", 0);
			if(eqpos>0){
				if((chkval.substring(0,eqpos+1))==arg){
					retval=true;
					break;
				}	
			}
		}
		prev=next+2;
	}
	return retval;
}

function displayCatfishAdPA(){
	if(!GetPACookie("showCatfishAdPA")){
		document.getElementById("catfish").style.display="block";	
	}else{
		document.getElementById("footergap").style.display="none";
	}
}

function closeCatfishAdPA(){
	SetPACookie("showCatfishAdPA","yes");
	document.getElementById("footergap").style.display="none";
	document.getElementById("catfish").style.display="none";
}

function hasSpecialChars(txtStr) {
	var regExp = /[^0-9a-zA-Z._-]/;
	if (txtStr.length>0)
		return (regExp.test(txtStr));
	else
		return false;
}

function checkValidPW(formObj,invalidDivID) {
	var retVal = true;
	if (formObj.value.length > 0) {
		hideBox(invalidDivID);
		if (hasSpecialChars(formObj.value)) {
			showBox(invalidDivID);
			retVal = false;
			//formObj.value = '';
		}
	} else {
		hideBox(invalidDivID);
	}
	return retVal;
}
/* FROM DHTMLWINDOW */
// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// v1.1:  Oct 29th, 07' (see changelog.txt)
// -------------------------------------------------------------------

var dhtmlwindow={
imagefiles:['http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/CLOSE-X.GIF'], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?

minimizeorder: 0,
zIndexvalue:100,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
lastactivet: {}, //reference to last active DHTML window

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	domwindow.className="dhtmlwindow"
	var domwindowdata=''
	domwindowdata='<div class="drag-handle">'
	domwindowdata+='DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[0]+'" title="Close" /></div>'
	domwindowdata+='</div>'
	domwindowdata+='<div class="drag-contentarea"></div>'
	domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea">&nbsp;</div></div>'
	domwindowdata+='</div>'
	domwindow.innerHTML=domwindowdata
	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	//this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t=document.getElementById(t)
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	//t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.resizearea._parent=t //same
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.setfocus(this)} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.hide(this)} //public function for hiding dhtml window
	t.close=function(){dhtmlwindow.close(this)} //public function for closing dhtml window (also empties DHTML window content)
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	this.setfocus(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	//var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var xpos="middle"
	var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	//t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
	t.isResize(getValue("resize")) //Set whether window is resizable
	t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	t.moveTo(xpos, ypos) //Position window
	t.load(contenttype, contentsource, title)
	if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
		//t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		t.controls.firstChild.setAttribute("title", "Minimize")
		t.state="fullview" //indicate the state of the window as being "fullview"
	}
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},

isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	t.statusarea.style.display=(bol)? "block" : "none"
	t.resizeBool=(bol)? 1 : 0
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	if (t.isClosed){
		alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
		return
	}
	var contenttype=contenttype.toLowerCase() //convert string to lower case
	if (typeof title!="undefined")
		t.handle.firstChild.nodeValue=title
	if (contenttype=="inline")
		t.contentarea.innerHTML=contentsource
	else if (contenttype=="div"){
		var inlinedivref=document.getElementById(contentsource)
		t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
		if (!inlinedivref.defaultHTML)
			inlinedivref.defaultHTML=inlinedivref.innerHTML //save HTML within inline DIV
		inlinedivref.innerHTML="" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
		inlinedivref.style.display="none" //hide that div
	}
	else if (contenttype=="iframe"){
		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			t.contentarea.innerHTML='<iframe src="" scrolling="no" style="margin:0; padding:0; width:100%; height: 100%" marginwidth=0 marginheight=0 frameborder=0 name="_iframe-'+t.id+'"></iframe>'
		window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
	else if (contenttype=="ajax"){
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
	t.contentarea.datatype=contenttype //store contenttype of current window for future reference

	var selectList = document.getElementsByTagName('select');
	for (i=0; i<selectList.length; i++) {
		selectList[i].style.display = "none";
	}
},

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	d.initmousey=e.clientY
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
		d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},

resize:function(t, e){
	t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		d.minimize(sourceobj, this._parent)
	else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		d.restore(sourceobj, this._parent)
	else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	return false
},

minimize:function(button, t){
	dhtmlwindow.rememberattrs(t)
	//button.setAttribute("src", dhtmlwindow.imagefiles[2])
	button.setAttribute("title", "Restore")
	t.state="minimized" //indicate the state of the window as being "minimized"
	t.contentarea.style.display="none"
	t.statusarea.style.display="none"
	if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
		dhtmlwindow.minimizeorder++ //increment order
		t.minimizeorder=dhtmlwindow.minimizeorder
	}
	t.style.left="10px" //left coord of minmized window
	t.style.width="200px"
	var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
},

restore:function(button, t){
	dhtmlwindow.getviewpoint()
	//button.setAttribute("src", dhtmlwindow.imagefiles[0])
	button.setAttribute("title", "Minimize")
	t.state="fullview" //indicate the state of the window as being "fullview"
	t.style.display="block"
	t.contentarea.style.display="block"
	if (t.resizeBool) //if this window is resizable, enable the resize icon
		t.statusarea.style.display="block"
	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
	t.style.width=parseInt(t.lastwidth)+"px"
},


close:function(t){
	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		if (window.frames["_iframe-"+t.id]) //if this is an IFRAME DHTML window
			window.frames["_iframe-"+t.id].location.replace("about:blank")
		else
			t.contentarea.innerHTML=""
		t.style.display="none"
		if(document.inquiry && window.navigator.userAgent.indexOf("Chrome") != -1){//for Chrome
			var inps = $("input:visible").serializeArray();
			var sels = $("select").serializeArray();
			var areas = $("textarea:visible").serializeArray();
			inps = inps.concat(sels,areas);
			document.inquiry.reset();
			$.each(inps, function(index, data){
				if(data.value != '')
					$($("[name="+data.name+"]")[0]).val(data.value);
			})
		}
		t.isClosed=true //tell script this window is closed (for detection in t.show())
	}
	return closewinbol
},


setopacity:function(targetobject, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	if (!targetobject)
		return
	if (targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value
	else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value
},

setfocus:function(t){ //Sets focus to the currently active window
	this.zIndexvalue++
	t.style.zIndex=this.zIndexvalue
	t.isClosed=false //tell script this window isn't closed (for detection in t.show())
	this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
	this.setopacity(t.handle, 1) //focus currently active window
	this.lastactivet=t //remember last active window
},


show:function(t){
	if (t.isClosed){
		alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
		return
	}
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	this.setfocus(t)
	t.state="fullview" //indicate the state of the window as being "fullview"
},

hide:function(t){
	t.style.display="none"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	t.contentarea.innerHTML=this.ajaxloadinghtml
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	t.contentarea.innerHTML=page_request.responseText
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	for (var i=0; i<dhtmlwindow.tobjects.length; i++){
		dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
	}
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup
/* FROM MODAL */
// -------------------------------------------------------------------
// DHTML Modal window- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 27th, 07'
// v1.01 May 5th, 07' Minor change to modal window positioning behavior (not a bug fix)
// v1.1: April 16th, 08' Brings it in sync with DHTML Window widget. See changelog.txt for the later for changes.
// REQUIRES: DHTML Window Widget (v1.01 or higher): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/
// -------------------------------------------------------------------

//if (typeof dhtmlwindow=="undefined")
//alert('ERROR: Modal Window script requires all files from "DHTML Window widget" in order to work!')

var dhtmlmodal={
veilstack: 0,
open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtmlwindow object
	this.interVeil=document.getElementById("interVeil") //Reference "veil" div
	this.veilstack++ //var to keep track of how many modal windows are open right now
	this.loadveil()
	if (recalonload=="recal" && d.scroll_top==0)
		d.addEvent(window, function(){dhtmlmodal.adjustveil()}, "load")
	var showXcontrol=(t=='UpdateProfileBox'? true:false); //added by dheil
	var t=d.open(t, contenttype, contentsource, title, attr, recalonload)
	//show for sso-overlay only
	if (showXcontrol)
		t.controls.firstChild.style.display="none" //Disable "minimize" button
	t.controls.onclick=function(){
		dhtmlmodal.close(this._parent, true)
	} //OVERWRITE default control action with new one
	
	t.show=function(){dhtmlmodal.show(this)} //OVERWRITE default t.show() method with new one
	t.hide=function(){dhtmlmodal.close(this)} //OVERWRITE default t.hide() method with new one
return t
},


loadveil:function(){
	var d=dhtmlwindow
	d.getviewpoint()
	this.docheightcomplete=(d.standardbody.offsetHeight>d.standardbody.scrollHeight)? d.standardbody.offsetHeight : d.standardbody.scrollHeight
	this.interVeil.style.width=d.docwidth+"px" //set up veil over page
	this.interVeil.style.height=this.docheightcomplete+"px" //set up veil over page
	this.interVeil.style.left=0 //Position veil over page
	this.interVeil.style.top=0 //Position veil over page
	this.interVeil.style.visibility="visible" //Show veil over page
	this.interVeil.style.display="block" //Show veil over page
},

adjustveil:function(){ //function to adjust veil when window is resized
	if (this.interVeil && this.interVeil.style.display=="block") //If veil is currently visible on the screen
		this.loadveil() //readjust veil
},

closeveil:function(){ //function to close veil
	this.veilstack--
	if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
		this.interVeil.style.display="none"
	var selectList = document.getElementsByTagName('select');
	for (i=0; i<selectList.length; i++) {
		selectList[i].style.display = "";
	}
},


close:function(t, forceclose){ //DHTML modal close function
	//t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe
	if (typeof forceclose!="undefined")
		t.onclose=function(){return true}
	if (dhtmlwindow.close(t)) //if close() returns true
		this.closeveil()
},


show:function(t){
	dhtmlmodal.veilstack++
	dhtmlmodal.loadveil()
	dhtmlwindow.show(t)
}
} //END object declaration
document.write('<div id="interVeil"></div>')
dhtmlwindow.addEvent(window, function(){if (typeof dhtmlmodal!="undefined") dhtmlmodal.adjustveil()}, "resize")
//add below for MR23578
function getEvent(){
    if (document.all) return window.event;
    func = getEvent.caller;
    while (func != null) {
        var arg0 = func.arguments[0];
        if (arg0) {
            if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
                return arg0;
            }
        }
        func = func.caller;
    }
    return null;
}

function pressEnter(){
	var e = getEvent();
	if(window.navigator.userAgent.indexOf('MSIE')>=1){
		if (e.keyCode == 13) {
			var a = parseInt($('#aItem0').attr("rel"));
			var txt = $("a[rel=" + a.toString() + "]").not($('#aItem0')).text();
			//fillinput(txt);
			return false;
		}
	}
}

function automail(inputString) {
	var event = getEvent();
	if(inputString==''||inputString.length == 0) {
		$('#automailBox').hide();
	} else {
		var a = parseInt($('#aItem0').attr("rel"));
		var cnt = document.getElementById("automailList").getElementsByTagName("a").length - 1;	
		if (event.keyCode == 40 && cnt > 0) {
			var b = a + 1;
			var c = b.toString();
			if (a == cnt) {
				$('#aItem0').attr("rel", 0);
				$("a[rel=0]").addClass("cur");
				$("a[rel="+cnt+"]").removeClass("cur");
			} else {
				$("a[rel=" + a.toString() + "]").removeClass("cur");
				$("a[rel=" + c + "]").addClass("cur");
				$('#aItem0').attr("rel", c);
			}
			return false;
		}
	
		if (event.keyCode == 38 && cnt > 0) {
			var b = a - 1;
			var c = b.toString();
			if (b == 0) {
				$('#aItem0').attr("rel", 0);
				$("a[rel=0]").addClass("cur");
				$("a[rel=1]").removeClass("cur");
			} else if(b<0){
				$('#aItem0').attr("rel", cnt);
				$("#aItem"+cnt).addClass("cur");
				$('#aItem0').removeClass("cur");
				$("a[rel=0]").removeClass("cur");
			}else {
				$("a[rel=" + a.toString() + "]").removeClass("cur");
				$("a[rel=" + c + "]").addClass("cur");
				$('#aItem0').attr("rel", c);
			}
			return false;
		}
	
		if (event.keyCode == 13) {				
			var txt = $("a[rel=" + a.toString() + "]").not($('#aItem0')).text();
			fillinput(txt);
			return false;
		}
		var data,mailstr,mailallstr
		var array= new Array("012.net.il","126.com","163.com","aapt.net.au","absamail.co.za","abv.bg","adinet.com.uy","aim.com",
			"airtelmail.in","alice.it","aol.co.uk","arcor.de","att.net","batelco.com.bh","bellnet.ca","bellsouth.net","bezeqint.net",
			"bigpond.com","bigpond.com.au","bigpond.net.au","biznetvigator.com","bk.ru","bluewin.ch","blueyonder.co.uk",
			"bol.com.br","brain.net.pk","btconnect.com","btinternet.com","btopenworld.com","cantv.net","cbn.net.id","centrum.cz",
			"cfl.rr.com","charter.net","clear.net.nz","cogeco.ca","comcast.net","connect.com.fj","consultant.com","cox.net","cyber.net.pk",
			"cytanet.com.cy","dataone.in","dhaka.net","dodo.com.au","earthlink.net","eim.ae","eircom.net","email.com","embarqmail.com",
			"emirates.net.ae","ethionet.et","fibertel.com.ar","foxmail.com","free.fr","freemail.hu","fsmail.net","gmai.com","gmx.com","gmx.de",
			"gmx.net","googlemail.com","hanmail.net","hotmail.ca","hotmail.co.uk","hotmail.com.au","hotmail.de","hotmail.es","hotmail.fr",
			"hotmail.it","iafrica.com","iburst.co.za","ig.com.br","ihug.co.nz","iinet.net.au","in.com","inbox.com","inbox.lv","inbox.ru",
			"indiatimes.com","interia.pl","internode.on.net","intnet.mu","iprimus.com.au","juno.com","laposte.net","libero.it","link.net",
			"list.ru","live.ca","live.cn","live.co.uk","live.co.za","live.com.au","live.fr","live.ie","live.in","live.nl","live.se","lycos.com","mac.com",
			"mail.com","mail.ru","maltanet.net","me.com","menara.ma","mindspring.com","msa.hinet.net","msn.com","mtnl.net.in","mweb.co.za",
			"naver.com","netspace.net.au","netvigator.com","netvision.net.il","netzero.com","netzero.net","neuf.fr","ntlworld.com","o2.pl",
			"online.no","onvol.net","optonline.net","optusnet.com.au","orange.fr","otenet.gr","ovi.com","ozemail.com.au","pacific.net.sg",
			"paran.com","planet.nl","prodigy.net.mx","q.com","qq.com","rambler.ru","rediff.com","roadrunner.com","rocketmail.com",
			"rogers.com","sapo.pt","sasktel.net","sbcglobal.net","scs-net.org","seznam.cz","shaw.ca","sify.com","sina.com",
			"singnet.com.sg","siol.net","sky.com","skynet.be","slingshot.co.nz","sltnet.lk","streamyx.com","sympatico.ca","talktalk.net",
			"tampabay.rr.com","telefonica.net","telenet.be","telia.com","telkomsa.net","telus.net","terra.com.br","tin.it","tiscali.co.uk",
			"tiscali.it","tm.net.my","t-online.de","tpg.com.au","tstt.net.tt","ukr.net","une.net.co","uol.com.br","usa.com","verizon.net",
			"videotron.ca","vip.163.com","virgilio.it","virgin.net","vodamail.co.za","vsnl.com","vsnl.net","vtr.net","walla.co.il","walla.com",
			"wanadoo.fr","web.de","webmail.co.za","westnet.com.au","windowslive.com","windstream.net","wlink.com.np","wp.pl",
			"xtra.co.nz","yahoo.ca","yahoo.cn","yahoo.co.id","yahoo.co.kr","yahoo.co.nz","yahoo.com.ar","yahoo.com.au","yahoo.com.br",
			"yahoo.com.cn","yahoo.com.hk","yahoo.com.mx","yahoo.com.my","yahoo.com.ph","yahoo.com.sg","yahoo.com.tw","yahoo.de",
			"yahoo.es","yahoo.fr","yahoo.gr","yahoo.ie","yahoo.in","yahoo.it","yahoomail.com","yandex.ru","yeah.net","ymail.com","zahav.net.il");
		array.sort();
		var arrayTop=new Array("gmail.com","yahoo.com","hotmail.com","aol.com","yahoo.co.uk","yahoo.co.in","live.com","rediffmail.com");
		data = "<h2 class='title'>Please select your e-mail address</h2>";
		if(window.navigator.userAgent.indexOf('Firefox/3.6')>0) 
		//if(window.navigator.userAgent.indexOf('MSIE')<0) 
			data = data+"<a href='#' id='aItem0' class='cur' rel='0' onmousedown=fillinput('"+inputString+"')>"+inputString+"</a>";
		else
			data = data+"<a href='#' id='aItem0' class='cur' rel='0'>"+inputString+"</a>";
	
		if(inputString.indexOf("@") ==-1) {
			for(i=0;i<=7;i++){data = data+"<a href='#' id='aItem"+(i+1)+"' rel='"+(i+1)+"' onmousedown=fillinput('"+inputString+"@"+arrayTop[i]+"')><b>"+inputString+"</b>@"+arrayTop[i]+"</a>";
			}
		}
	
		if(inputString.length-1==inputString.lastIndexOf("@")) {
			for(i=0;i<=7;i++){data = data+"<a href='#' id='aItem"+(i+1)+"' rel='"+(i+1)+"'onmousedown=fillinput('"+inputString+arrayTop[i]+"')><b>"+inputString+"</b>"+arrayTop[i]+"</a>";}
		}
	
		if(inputString.lastIndexOf("@")>0 && inputString.length-1>inputString.lastIndexOf("@")) {
			mailstr = inputString.substring(0,inputString.lastIndexOf("@")+1);
			cnt = 0;
			for(i=0;i<array.length && cnt<8;i++){
				mailallstr = mailstr+array[i]
				if (mailallstr.indexOf(inputString) ==0){
					cnt++;
					data = data+"<a href='#' id='aItem"+(cnt)+"' rel='"+(cnt)+"' onmousedown=fillinput('"+mailstr+array[i]+"')><b>"+mailstr+"</b>"+array[i]+"</a>";
				}
			}
		}
		$('#countryCode').hide();
		$('#automailBox').fadeIn();
		$('#automailList').html(data);			
	}
}

function emailFocus(){
	document.inquiry.enterFrom.value="email";
	showBox('TipEmail');
}

function sub(inqType){
	var a = parseInt($('#aItem0').attr("rel"));
	if(a>0){
		var txt = $("a[rel=" + a.toString() + "]").not($('#aItem0')).text();
		document.inquiry.contact_detail_email.value = txt;
	}
			
	if(document.inquiry.enterFrom.value=="email"){
		document.inquiry.enterFrom.value="";
		if(window.navigator.userAgent.indexOf('MSIE')<0){//double check for non-IE
			if(checkFilledMandatory(document.inquiry.contact_detail_email,'ReqdEmail','value')) 
				checkEmail(document.inquiry.contact_detail_email, 'InvalidEmail','ReqdEmail');
		}
		emailFocus();
		document.inquiry.contact_detail_email.focus();
		return false;
	}

	return chkTxAreas(inqType);
}

function fillinput(thisValue) {
	document.inquiry.enterFrom.value="";
	$('#automailBox').hide();
	$('#countryCode').show();
	if (thisValue==null){
		thisValue="";
		//setTimeout(function(){document.inquiry.contact_detail_email.focus();}, 10);
		if(window.navigator.userAgent.indexOf('MSIE')<0&&checkFilledMandatory(document.inquiry.contact_detail_email,'ReqdEmail','value')) {
			var isValid = checkEmail(document.inquiry.contact_detail_email, 'InvalidEmail','ReqdEmail');
			//if(!isValid) setTimeout(function(){document.inquiry.contact_detail_email.focus();}, 10);
			return isValid;
				//document.inquiry.contact_detail_email.focus();									
		}
	}
	if(thisValue.length >0) {
		document.inquiry.contact_detail_email.value=thisValue;
		emailFocus();	
		//document.inquiry.contact_detail_email.focus();
		setTimeout(function(){document.inquiry.contact_detail_email.focus();}, 10);
		if(checkFilledMandatory(document.inquiry.contact_detail_email,'ReqdEmail','value')) {			
			return checkEmail(document.inquiry.contact_detail_email, 'InvalidEmail','ReqdEmail');
				//document.inquiry.contact_detail_email.focus();									
		}		
	}
	//setTimeout(function(){document.inquiry.contact_detail_email.focus();}, 10);
}
function popBuyerInf(page,height,width) {
	params = "height=" + height + ",width=" + width + ",status=1,toolbar=0,directories=0,menubar=0,location=0,scrollbars=0,resizable=1,top=50,left=50,screenX=50,screenY=50";
	mypopup = window.open(page,"PopupWindow",params);
	mypopup.focus();
}

