// This method will only add two positive numbers which should be passed as stringsfunction add(x,y) {	var num1 = x;	var num2 = y;	if(num1.length < num2.length){		num1 = y;		num2 = x;	}		//num1 length is always greater than or equal to num2 length	num1 = reverseString(num1);	num2 = reverseString(num2);	//adding tailing 0's for smaller length num	var tailingZeros = "";	for(i=0; i<(num1.length - num2.length);i++){		tailingZeros = tailingZeros+'0';	}	num2 = num2+tailingZeros;	var num1Ary = new Array(num1.length);	var num2Ary = new Array(num2.length);		num1Ary = num1.split("");	num2Ary = num2.split("");	if(num1Ary.length == num2Ary.length){		var carry = 0;		var retStr = "";		for(i=0; i< num1Ary.length; i++){			var dx = 0;			var dy = 0;			var sum = 0;			dx = parseInt(num1Ary[i]);			try{				dy = parseInt(num2Ary[i]);			}catch(e){				dy = 0;			}			sum = dx + dy + carry;			var c = sum.toString();			if(c.length == 2){				retStr = retStr + c.charAt(1);				carry = 1;							}else{				carry = 0;				retStr = retStr + c;			}		}		if(carry == 1){			retStr = retStr + carry		}		retStr = reverseString(retStr);	}	return retStr;}//This will always subtract the smaller number from the bigger num no matter what order you give infunction sub(x,y) {	var num1 = x;	var num2 = y;	if(num1.length < num2.length){		num1 = y;		num2 = x;	}		//num1 length is always greater than or equal to num2 length	num1 = reverseString(num1);	num2 = reverseString(num2);	//adding tailing 0's for smaller length num	var tailingZeros = "";	for(i=0; i<(num1.length - num2.length);i++){		tailingZeros = tailingZeros+'0';	}	num2 = num2+tailingZeros;	var num1Ary = new Array(num1.length);	var num2Ary = new Array(num2.length);		num1Ary = num1.split("");	num2Ary = num2.split("");	if(num1Ary.length == num2Ary.length){		var carry = 0;		var retStr = "";		for(i=0; i< num1Ary.length; i++){			var dx = 0;			var dy = 0;			var diff = 0;			dx = parseInt(num1Ary[i]);			try{				dy = parseInt(num2Ary[i]);			}catch(e){				dy = 0;			}			diff = dx - dy - carry;			var c = diff.toString();			if(c.length >= 2){				diff = diff+10;				retStr = retStr + diff;				carry = 1;							}else{				carry = 0;				retStr = retStr + c;			}		}		retStr = reverseString(retStr);	}	return retStr;}function reverseString(str){	var temp = new Array(str.length);	temp = str.split("");	temp = temp.reverse();	var rStr = "";	for(i=0; i< temp.length; i++){		rStr = rStr+temp[i];	}	return rStr;}/* Browser Detection */var agent 	= navigator.userAgent.toLowerCase();
var isIE 	= (agent.indexOf('msie') != -1);
var isIE5 	= (agent.indexOf('msie 5') != -1);function helpOn(id){	document.getElementById(id).style.display='block';}function helpOff(id){	document.getElementById(id).style.display='none';}
/* Incontext Help */function showHelp() {  obj = document.getElementById('help_show');
  obj.style.display = 'block';
  obj = document.getElementById('help_hide');
  obj.style.display = 'none';
}function hideHelp(iid) {
  obj = document.getElementById('help_show');
  obj.style.display = 'none';
  obj = document.getElementById('help_hide');
  obj.style.display = 'block';
}/* Windows */function openWindow(url, myname, w, h){	var scroll = 'no';
	var resize = 'no';
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var props = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize;
	popupWin = window.open(url, myname, props);
	popupWin.focus();}function addAttribute (name){	obj = document.getElementById(name);	var attribName = name.substr(0,name.indexOf("_attrib"));
	obj.innerHTML="<span class='blueLink'><strong>Enter Attribute</strong></span> <input type='text' name='" + attribName + "' class='formField' style='width: 150px'> <span class='formButtonSubmitBorder'><input type='button' style='width: 60px' name='s' value='ADD' onclick='this.form.btnAction.value=\"add\";this.form.submit()' class='formButtonSubmit'></span><span class='formButtonBorder' ><input type='button' style='width: 60px' name='s' value='CANCEL' class='formButton' onclick='cancelAttribute(\""+name+"\")'></span>";
}function addLink (name){	obj = document.getElementById(name);	var attribName = name.substr(0,name.indexOf("_attrib"));	obj.innerHTML="<table cellpadding='2' cellspacing ='0'><tr><td><span class='blueLink'><strong>Enter Link Title</strong></span> <span style='color:#000000; font-size:10px;'>(Example: My Auction, My Site, Buy Now)</span></td></tr><tr><td><input type='text' onBlur='formLink()' id='linkTitle' name='" + attribName +"_title' class='formField' style='width: 150px'></td></tr><tr><td><span class='blueLink'><strong>Enter Link URL</strong></span> <span style='color:#000000; font-size:10px;'>(Example: http://www.myauction.com)</span></td></tr><tr><td><input type='text' onBlur='formLink()' id='linkURL' name='" + attribName +"_url' class='formField' style='width: 250px'></td></tr><tr><td colspan='2'><input type='hidden' id='linkStr' name='" + attribName +"_new' /><span class='formButtonSubmitBorder'><input type='button' style='width: 60px' name='s' value='ADD'  onclick='if(validateURL()){if(validateTitle()){this.form.submit();}else{alert(\"Title Field cannot be blank\")}}else{alert(\"This is not a valid url\")}' class='formButtonSubmit'></span><span class='formButtonBorder' ><input type='button' style='width: 60px' name='s' value='CANCEL' class='formButton' onclick='cancelLink(\""+name+"\")'></span></td></tr></table>";}function addVideo(){	obj = document.getElementById('videoType');	obj2 = document.getElementById('videoSourceContainer');	if(obj.value != null && obj.value != ""){		obj2.style.display = "block";		obj3 = document.getElementById('videoSource');		if(obj3.value == null || obj3.value == ""){			obj3.value="Please copy and paste the code here";		}	}else{		obj2.style.display = "none";	}}function clearComment(name){	obj = document.getElementById(name);	if(obj.value == 'Please copy and paste the code here'){		obj.value = "";	}}function cancelLink (name){	obj = document.getElementById(name);	obj.innerHTML="<a href='javascript:addLink(\""+name+"\")'><img src='images/icons/add.gif' width='20' height='20' border='0' align='absmiddle'></a> <a href='javascript:addLink(\""+name+"\")' class='blueLink'><strong>Add Link</strong></a>";}function submitLink(){	this.form.btnAction.value= 'addLink';	if(validateURL()){		this.form.submit();	}else{		alert('Is not a Valid URL');	}}function validateTitle(){	var title = document.getElementById('linkTitle').value;	if(title != null){		title = title.replace(/\s+/gm, "");	}	if(title == ""){		return false;	}else{		return true;	}}function validateURL(){	var url = document.getElementById('linkURL').value;	if (/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(url)){		return (true);	} else {		return (false);	}}function validateEmail(email) {	 var emailReg = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;	 var regex = new RegExp(emailReg);	 if (regex.test(email)){		return true;	} else {		return false;	}}function formLink(){	//var charCode = window.event.keyCode;	var objTitle = document.getElementById('linkTitle');	var objURL = document.getElementById('linkURL');	if(objTitle.value.indexOf('"') != -1){		alert("Double Quotes are not allowed");		objTitle.value = objTitle.value.replace('"','');	}	if(objURL.value.indexOf('"') != -1){		alert("Double Quotes are not allowed");		objURL.value = objURL.value.replace('"','');	}	var check = objURL.value.toLowerCase();	if(check.indexOf('javascript:') != -1){		check = check.replace('javascript:','');		objURL.value = check;		alert('Javascript not allowed');	}		//if(charCode == 222){		//objTitle.value = objTitle.value.replace("'","");		//objURL.value = objURL.value.replace("'","");		//objTitle.value = objTitle.value.replace('"','');		//objURL.value = objURL.value.replace('"','');		//alert("Quotes or Double Quotes are not allowed");		//return false;	//}	var title = objTitle.value; 	var url = objURL.value;	var link = '<a class="link" href="'+url+'">'+title+'</a>';	document.getElementById('linkStr').value = link;}function cancelAttribute (name){	obj = document.getElementById(name);	obj.innerHTML="<a href='javascript:addAttribute(\""+name+"\")'><img src='images/icons/add.gif' width='20' height='20' border='0' align='absmiddle'></a> <a href='javascript:addAttribute(\""+name+"\")' class='blueLink'><strong>Add Attribute</strong></a>";}
function addProdAttribute (name){	obj = document.getElementById(name);	obj.innerHTML="<span class='blueLink'><strong>Enter Label</strong></span> <input type='text' name='" + name + "' class='formField' style='width: 150px'>&nbsp;<select name='" + name + "_type' class='formField' style='font-weight:normal;'><option value='CHAR'>Text</option><option value='CHAR'>Number</option><option value='DATE'>Date</option></select>&nbsp;<span class='formButtonSubmitBorder'><input type='button' style='width: 60px' name='s' value='ADD' onclick='this.form.btnAction.value=\"addProdAttrib\";this.form.submit()' class='formButtonSubmit'></span><span class='formButtonBorder' ><input type='button' style='width: 60px' name='s' value='CANCEL' class='formButton' onclick='cancelProdAttribute(\""+name+"\")'></span>";}function cancelProdAttribute (name){	obj = document.getElementById(name);	obj.innerHTML="<a href='javascript:addProdAttribute(\""+name+"\")'><img src='images/icons/add.gif' width='20' height='20' border='0' align='absmiddle'></a> <a href='javascript:addProdAttribute(\""+name+"\")' class='blueLink'><strong>Add Field</strong></a>";}function addDropDownValue(id, charValue){	var customListValueName = "customListValue_"+id;	var obj1 = document.getElementById(id); //pa_269010	var obj2 = document.getElementById("cl_"+id); //cl_pa_269010	var obj3 = document.getElementById("container_"+id); //container_pa_269010	if(obj1.selectedIndex == obj1.length-1){		obj3.style.display = "none"		obj2.style.display = "inline"		if(charValue != "null" && charValue != ""){			obj2.innerHTML = "<div style=\"padding:0px;\"><input name=\""+customListValueName+"\" id=\""+customListValueName+"\" value=\""+charValue+"\" type=\"text\" /><br /><span class='formButtonSubmitBorder'><input type=\"button\" class='formButtonSubmit' style='width: 60px' value=\"UPDATE\" onclick=\"this.form.submit()\"/></span> <span class='formButtonBorder'><input type=\"button\" style='width: 60px' value='CANCEL' class='formButton' onclick=\"hideCustom('"+id+"','"+charValue+"')\"/></span></div>";		}else{			obj2.innerHTML = "<div style=\"padding:0px;\"><input name=\""+customListValueName+"\" id=\""+customListValueName+"\" value=\"\" type=\"text\" /><br /><span class='formButtonSubmitBorder'><input type=\"button\" value=\"ADD\" class='formButtonSubmit' style='width: 60px' onclick=\"this.form.submit()\"/></span> <span class='formButtonBorder'><input type=\"button\" style='width: 60px' value='CANCEL' class='formButton' onclick=\"hideCustom('"+id+"','')\"/></span></div>";		}	}}function hideCustom(id, charValue){	//alert(charValue);	var customListValueName = "customListValue_"+id;	if(document.all){		document.getElementById(customListValueName).value = charValue;		EDITOR.submit();	}else{		var obj1 = document.getElementById(id); //pa_269010		var obj2 = document.getElementById("cl_"+id); //cl_pa_269010		var obj3 = document.getElementById("container_"+id); //cl_pa_269010				obj3.style.display = "block";		obj2.style.display = "none";		obj1.selectedIndex = 0;	}}function  updateMainPicture (){	var checkObj = document.getElementById("mainPictureCheckbox");		var captionRowObj = document.getElementById("captionRow");	if (checkObj.checked){		captionRowObj.style.visibility='hidden';	} else {		captionRowObj.style.visibility='visible';	}}	function updateRatePeriod (){	var selectObj = document.getElementById("selectRatePeriod");
	var otherObj = document.getElementById("otherRatePeriodDiv");
	if (selectObj.selectedIndex==2){		otherObj.style.display='block';	} else {		otherObj.style.display='none';	}}function isNumberKey(evt){         var charCode = (evt.which) ? evt.which : event.keyCode         if (charCode > 31 && (charCode < 48 || charCode > 57)){         	alert("Only Numeric Values");            return false;         }         return true;}function validateZIP(fieldObj) {	var field = fieldObj.value;	var valid = "0123456789";	for (var i=0; i < field.length; i++) {		if (valid.indexOf(field.charAt(i)) == "-1") {			alert("Zip code must be five digit numeric value.");			fieldObj.value = "";			fieldObj.focus();			return false;		}	}	return true;}