var sInvalidChars

sInvalidChars="1234567890";

var iTotalChecked=0;

function checkNumericVals(objV,  msg)

{

	for(var i=0;i<sInvalidChars.length;i++)

	{

		if(objV.value.indexOf(sInvalidChars.charAt(i))!=-1)

		{

			alert(msg);

			objV.focus();

			return false;

		}

	}

	return true;

}

function objChecked(obj)

{

	if(obj.checked)

		iTotalChecked = iTotalChecked + 1

	else

		iTotalChecked = iTotalChecked - 1

 }

function fnSearch(iID)

{

	document.forms[0].HID_SearchID.value=iID;

	document.forms[0].action="../Users/Search.asp"

	document.forms[0].submit();

}

function fn_ValidateZipPhone(obj, iLen, sMsg)

{

	if(obj.value.length<iLen)

	{

		alert(sMsg);

		obj.select();

		obj.focus();

		return false;

	}

	return true;

}



function CheckConfirmPassword(fldPass,fldConPass,minChars)

{

	//created on: 30th Jan 2003

	//Programmer: Anita Mourya

	//Purpose	: This function is used to check that Password contains minimum characters and confirm Password matches the password. 

	//Arguments : password field name , confirm password field name, minimum characters to check.





		if(fldPass.value.length == 0)

		{

			alert("Please enter your password");

			fldPass.focus();

			fldPass.select();

			return false;

		}

		h = fldPass.value.length;

		x = fldPass.value.value;



			for( i=0;i<h;i++)

			{

			 

				if (  h < minChars )

				{

								alert(" Password can't be less than " + minChars + " characters");

								fldPass.focus();

								fldPass.select();

								return false;

				}





			}

		//=============================





		if(fldConPass.value.length == 0)

		{

			alert("Please re-enter your password");

			fldConPass.focus();

			fldConPass.select();

			return false;

		}

	

//	alert(fldPass.value);	

	//	alert(fldConPass.value);

		if(fldPass.value != fldConPass.value)

		{

			alert("Please ensure that you have entered the same password twice");

			fldConPass.focus();

			fldConPass.select();

			return false;

		}

	return true;



}





function CheckCharWithinField(fldName, fldAlias, chkChar)

{

	//created on: 30th Jan 2003

	//Programmer: Anita Mourya

	//Purpose	: This function is used to check that username does not contain any spaces. 

	//Arguments : field name object, field alias to be used, character to be checked



		b= fldName.value.length

		x= fldName.value

		

		if (x == "")

		{

			alert ("Please Enter Your " + fldAlias)

			fldName.focus();

			fldName.select();

			return false;

		}



		for( i=0;i<b;i++)

		{

			z = x.substring(i,i+1);

			if(z== chkChar)

			{

				alert("Please enter valid " + fldAlias + " without any '" + chkChar + "' in-between");

				fldName.focus();

				fldName.select();

				return false;

			}

		}

		//------------------------------



return true;

}

function SendtoPopup(obj,objaction,iwidth,iheight)

{

	if(ValidateForm(obj))

	{

		iLeft = parseInt(screen.width)/2-parseInt(iwidth)/2

		iTop = parseInt(screen.height)/2-parseInt(iheight)/2

		obj.target = "s"

		obj.method = "Post"

		obj.action = objaction

		win = 	window.open(objaction, "s", "toolbars=0, menubar=0, noresize, left=" + iLeft + ",top=" + iTop + ", width=" + iwidth + ", height=" + iheight)

		obj.submit(win)

	}

	else

	{

		return false;

	}

	return false;

}

function CheckAll(chk)

{

	//created on: 10th May 2002

	//Programmer: Prashant Sharma

	//Purpose	: This function is used to check all the checkboxes basedon state of chk checkbox. 

	//Arguments : checkbox object

	for (var i=0;i < document.forms[0].elements.length;i++)

	{

		var e = document.forms[0].elements[i];

		if (e.type == "checkbox")

		{

			e.checked = chk.checked;

		}

	}

}



function fnRemoveSpaces(sFldval)

{

	var sTemp=sFldval;

  var sNewval=sTemp;

  //remove spaces from the front

  for(var i=0;i<sTemp.length;i++)

  {	

		if(sTemp.charAt(i)!=" ")

			break;

		else

			sNewval = sTemp.substring(i+1);

	}

	return sNewval;

}



function fnFixSpace(sFldval)

{

	//created on: 10th May 2002

	//Programmer: Prashant Sharma

	//Purpose	: This function is used to remove spaces. 

	//Arguments : text field object value

	var sTemp=sFldval;

  var sReversedString="";

  var sTemp1;

  

  //remove spaces from the front

  sNewval = fnRemoveSpaces(sTemp);

  

  // reverse n remove spaces from the front

  for(var i=sNewval.length-1;i>=0;i--)

		sReversedString = sReversedString + sNewval.charAt(i);

	sTemp1 = fnRemoveSpaces(sReversedString);

	//reverse again

	sReversedString="";

	for(var i=sTemp1.length-1;i>=0;i--)

		sReversedString = sReversedString + sTemp1.charAt(i);

	sNewval = sReversedString;

	return sNewval;

}



function ValidateEMail(objName)

{

	//created on: 12th May 2002

	//Programmer: Naveen Sharma

	//Purpose	: This function is used to validate email. 

	//Arguments : Email object

		

	var sobjValue;

	var iobjLength;

	

	sobjValue=objName;

	iobjLength=sobjValue.length;

	iFposition=sobjValue.indexOf("@");

	iSposition=sobjValue.indexOf(".");

	iTmp=sobjValue.lastIndexOf(".");	

	iPosition=sobjValue.indexOf(",");

	iPos=sobjValue.indexOf(";");

	

	if (iobjLength!=0)

	{

		if ((iFposition == -1)||(iSposition == -1))

		{

			return false;

		}

		else if(sobjValue.charAt(0) == "@" || sobjValue.charAt(0)==".")

		{

			return false;				

		}

		else if(sobjValue.charAt(iobjLength) == "@" ||

sobjValue.charAt(iobjLength)==".")

		{

			return false;				

		}	

		else if((sobjValue.indexOf("@",(iFposition+1)))!=-1)

		{	

			return false;

		}

		else if ((iobjLength-(iTmp+1)<2)||(iobjLength-(iTmp+1)>3))

		{

			return false;

		}

		else if ((iPosition!=-1) || (iPos!=-1))

		{

			return false;

		}

		else

		{

			return true;

		}		

	}		

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.0

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && document.getElementById) x=document.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



/*--------------------------------------------------------------------------------------

	this sub routine checks for the mandatory fields, their data types and maximum length

	also validates valid email entered or not

	Return : True/False

	Input : objFrm ( form object name)

	Programmer : Naveen Sharma

	Dated : 22-05-2002

	Version : 1.0.0

----------------------------------------------------------------------------------------*/

function ValidateForm(objFrm)

{

	var iConventionPos;

	var sChangedName;

	for( var i =0; i< objFrm.length;i++)

	{

		if(objFrm[i].type=='text' || objFrm[i].type=='textarea' || objFrm[i].type=='select-one' || objFrm[i].type=='select-multiple' || objFrm[i].type=='password')

		{

			if(objFrm[i].type=='text' || objFrm[i].type=='textarea' || objFrm[i].type=='password')

				objFrm[i].value = fnFixSpace(objFrm[i].value);

			

			var objDataTypeHolder = objFrm[i].name.substring(0,3);

			if(objFrm[i].name.substring(0,5)=='TREF_' || objFrm[i].name.substring(0,5)=='TNEF_'  || objFrm[i].name.substring(0,5)=='POKR_')

				objDataTypeHolder = objFrm[i].name.substring(0,5);

			if((objFrm[i].type=='select-one' && objFrm[i].options[objFrm[i].selectedIndex].value=='' && objDataTypeHolder=="TR_"))

			{

				sChangedName = objFrm[i].name.substring(3);

				sChangedName = getFormattedmsg(sChangedName);

				alert("Please select "+ sChangedName +".");

				objFrm[i].focus();

				return false;

				break;

			}



			if(objFrm[i].type=='password' && objFrm[i].value!='' && objFrm[i].value.indexOf(" ")!=-1)

			{

				alert("Spaces are not allowed in password.");

				objFrm[i].select();

				return false;

				break;

			}

			if(objFrm[i].type=='password' && objFrm[i].name=='TR_Confirm_Password' && objFrm[i].value!=objFrm.TR_Password.value)

			{

				alert("Password and confirm password fields are not matching.");

				objFrm[i].select();

				return false;

				break;

			}

			if(objFrm[i].type=='password' && objFrm[i].name=='TR_Confirm_New_Password' && objFrm[i].value!=objFrm.TR_New_Password.value)

			{

				alert("New Password and confirm New password fields are not matching.");

				objFrm[i].select();

				return false;

				break;

			}

			if((objDataTypeHolder=="UN_" || objDataTypeHolder=="TR_" || objDataTypeHolder=="IR_" || objDataTypeHolder=="MR_"  )&& (objFrm[i].value==''))

			{	

				sChangedName = objFrm[i].name.substring(3);

				sChangedName = getFormattedmsg(sChangedName)



				alert("Please enter "+ sChangedName +".");

				objFrm[i].focus();

				return false;

				break;

			}

			

			if((objDataTypeHolder=="TREF_" || objDataTypeHolder=="POKR_")  && objFrm[i].value=='')

			{

				sChangedName = objFrm[i].name.substring(5);

				sChangedName = getFormattedmsg(sChangedName);

			

				alert("Please enter "+ sChangedName +".");

				objFrm[i].focus();

				objFrm[i].select();

				return false;

				break;

			}						

			if(objFrm[i].name=='TREF_Confirm_email' && objFrm[i].value!=objFrm.TREF_email.value)

			{

				alert("Email and confirm email fields are not matching.");

				objFrm[i].focus();

				objFrm[i].select();

				return false;

				break;

			}	

			if((objDataTypeHolder=="IR_" || objDataTypeHolder=="MR_" )&& (isNaN(objFrm[i].value)))

			{

				sChangedName = objFrm[i].name.substring(3);

				sChangedName = getFormattedmsg(sChangedName)

				alert("Please enter numeric "+ sChangedName +".");

				objFrm[i].focus();

				objFrm[i].select();

				return false;

				break;

			}

			if(objDataTypeHolder=="UN_" && objFrm[i].value!='' && objFrm[i].value.indexOf(" ")!=-1)

			{

				sChangedName = objFrm[i].name.substring(3);

				sChangedName = getFormattedmsg(sChangedName)

				alert("Spaces are not allowed in "+ sChangedName +".");

				objFrm[i].focus();

				objFrm[i].select();

				return false;

				break;

			}			



			if((objDataTypeHolder=="IN_" || objDataTypeHolder=="MN_" )&& (isNaN(objFrm[i].value) && objFrm[i].value!='' ))

			{

				sChangedName = objFrm[i].name.substring(3);

				sChangedName = getFormattedmsg(sChangedName)

				alert("Please enter numeric "+ sChangedName +".");

				objFrm[i].focus();

				objFrm[i].select();

				return false;

				break;

			}



			if((objDataTypeHolder=="TREF_" || objDataTypeHolder=="TNEF_" || objDataTypeHolder=="POKR_" ) && objFrm[i].value!='' )

			{

			

				if(objDataTypeHolder=="POKR_"){

					var ln=objFrm[i].value.length;

					var postfix=objFrm[i].value.substr(ln-17,17);	

					if(postfix!="wharton.upenn.edu"){

						alert("Please enter valid email.");

						objFrm[i].focus();

						objFrm[i].select();

						return false;

						break;					

					}

				}

								

				if(!ValidateEMail(objFrm[i].value))

				{

					alert("Please enter valid email.");

					objFrm[i].focus();

					objFrm[i].select();

					return false;

					break;

				}

				

			}

			

			//ValidateNumber(objName)

			if((objDataTypeHolder=="NR_"))

			{

				if(!ValidateNumber(objFrm[i].value))

				{

					objFrm[i].focus();

					return false;

					break;

				}

			}			

			if(objDataTypeHolder=="PHR")

			{

				var val=objFrm[i].value;

				if (val!="")

				{

					for(var j=0; j < val.length;j++)

					{

						if((val.charAt(j)!='(')&&(val.charAt(j)!=')')&&(val.charAt(j)!=' ')&&(val.charAt(j)!="-")&& !((val.charAt(j)>=0)&&(val.charAt(j)<=9)))

						{

							alert("Please enter valid Phone Number");

							objFrm[i].focus();

							objFrm[i].select();

							return false;

							break;

						}

					}

				}

				else

				{

					alert("Please Enter Phone Number");

					objFrm[i].focus();

					objFrm[i].select();

					return false;

					break;

				}

			}

			//ValidateNumber(objName)

			if((objDataTypeHolder=="NR_"))

			{

				if(!ValidateNumber(objFrm[i].value))

				{

					objFrm[i].focus();

					return false;

					break;

				}

				if(parseFloat(objFrm[i].value)<=0)

				{

					objFrm[i].focus();	

					alert('Price should be greater then 0');

					return false;

				}

			}

			if(objDataTypeHolder=="PHN")

			{

				var val=objFrm[i].value;

				if (val!="")

				{

					for(var j=0; j < val.length;j++)

					{

						if((val.charAt(j)!='(')&&(val.charAt(j)!=')')&&(val.charAt(j)!=' ')&&(val.charAt(j)!="-")&& !((val.charAt(j)>=0)&&(val.charAt(j)<=9)))

						{

							alert("Please enter valid Phone Number");

							objFrm[i].focus();

							objFrm[i].select();

							return false;

							break;

						}

					}

				}				

			}

		}

		

		var objDataTypeHolder = objFrm[i].name.substring(0,3);

		sChangedName = objFrm[i].name.substring(3);

		sChangedName = getFormattedmsg(sChangedName);



		if(objFrm[i].type=='checkbox' && objDataTypeHolder=='CH_' && objFrm[i].checked==false){

			alert("You must check "+sChangedName);

			return false;

		}		



		if(objFrm[i].type=='file' && objDataTypeHolder=='FL_' && objFrm[i].value==''){

			alert("Please enter "+sChangedName);

			objFrm[i].focus();

			return false;

		}

		/*

		images extension list

		JPEG,JPG,EXIF,IPTC,TIFF,TIF,BMP,GIF,PNG,PIC,CEL,CUT,PAL,EPS,ICO,PCD,PCX,PCC,SCR,PSP,PSD,PDD,PBM,PPM,

		PGM,RLA,RPF,QBMP,BW,RGB,RGBA,SGI,TGA,VST,ICB,VDA,WIN,WMF,EMF,WBMP

		*/

		

		if(objFrm[i].type=='file' && objDataTypeHolder=='FL_' && objFrm[i].value!=''){

				var len=objFrm[i].value.length;

				var ext=objFrm[i].value.substr(len-4,4);

				ext=ext.toLowerCase();

				if(len>0 && ext!='jpeg' && ext!='.jpg' && ext!='exif' && ext!='iptc' && ext!='tiff' && ext!='.tif' && ext!='.bmp' && ext!='.gif' && ext!='.png' && ext!='.pic' && ext!='.cel' && ext!='.cut' && ext!='.pal' && ext!='.eps' && ext!='.ico' ){							

					alert("Please browse \n jpeg OR jpg OR exif OR iptc OR tiff OR tif OR bmp OR gif OR png OR pic OR cel OR cut OR pal OR eps OR ico \n type only");

					objFrm[i].focus();

					return false;

				} 		

		}		

		if(objFrm[i].type=='file' && objDataTypeHolder=='FE_' && objFrm[i].value!=''){

				var len=objFrm[i].value.length;

				var ext=objFrm[i].value.substr(len-4,4);

				ext=ext.toLowerCase();										

				if(len>0 && ext!='jpeg' && ext!='.jpg' && ext!='exif' && ext!='iptc' && ext!='tiff' && ext!='.tif' && ext!='.bmp' && ext!='.gif' && ext!='.png' && ext!='.pic' && ext!='.cel' && ext!='.cut' && ext!='.pal' && ext!='.eps' && ext!='.ico' ){							

					alert("Please browse \n jpeg OR jpg OR exif OR iptc OR tiff OR tif OR bmp OR gif OR png OR pic OR cel OR cut OR pal OR eps OR ico \n type only");

					objFrm[i].focus();

					return false;

				} 		

		}

// validation for video clips---------------------------------> begin  wmv mov		



		if(objFrm[i].type=='file' && objDataTypeHolder=='VC_' && objFrm[i].value==''){

			alert("Please enter "+sChangedName);

			objFrm[i].focus();

			return false;

		}

		

		if(objFrm[i].type=='file' && objDataTypeHolder=='VC_' && objFrm[i].value!=''){

				var len=objFrm[i].value.length;

				var ext=objFrm[i].value.substr(len-4,4);

				ext=ext.toLowerCase();

				if(len>0 && ext!='.mov' && ext!='.wmv' ){							

					alert("Please browse mov OR wmv type only");

					objFrm[i].focus();

					return false;

				} 		

		}		

		if(objFrm[i].type=='file' && objDataTypeHolder=='VE_' && objFrm[i].value!=''){

				var len=objFrm[i].value.length;

				var ext=objFrm[i].value.substr(len-4,4);

				ext=ext.toLowerCase();										

				if(len>0 && ext!='.mov' && ext!='.wmv' ){							

					alert("Please browse mov OR wmv type only");

					objFrm[i].focus();

					return false;

				} 		

		}

// validation for video clips---------------------------------> end		

				

	}

	return true;

}





function FormatDate(d)

{

		var dd,mm;

		var l;

		l=d.indexOf("/");

		dd=d.substring(0,l);

		d=d.substring(l+1);

		l=d.indexOf("/");

		mm=d.substring(0,l);

		yy=d.substring(l+1);

		

		if (parseInt(dd) < 10)

			dd="0" + dd;

		if (parseInt(mm) < 10)

			mm="0" + mm;

		d= dd + "/" + mm + "/" + yy

		alert(d);

		return d;

		

}



function ValidateImg(objImg, isRequired)

{

	if(isRequired ==1 && objImg.value=='')

	{

		alert("Please enter image.");

		objImg.focus();

		return false;

	}

	if(objImg.value.length!=0)

	{

		if(objImg.value.length<5)

		{

			alert("Please enter valid image.");

			objImg.focus();

			objImg.select();

			return false;

		}

		var iPos = objImg.value.lastIndexOf(".")

		var sExt = objImg.value.substring(iPos);

		if((sExt.toUpperCase()=='.JPEG') || (sExt.toUpperCase()=='.JPG') || (sExt.toUpperCase()=='.GIF') || (sExt.toUpperCase()=='.BMP') )

		{

			return true;

		}

		else

		{

			alert("Please enter valid image.");

			objImg.focus();

			objImg.select();

			return false;

		}

	}

	return true;

}



function ValidateNumber(objName)

{

	//created on: 12th May 2002

	//Programmer: Naveen Sharma

	//Purpose	: This function is used to validate price. 

	//Arguments : Email object

		

	var h;

	var x;

	

	h=objName.length;

	x = objName;

	if (h==0)

	{

		alert("Price Can be numeric only");

		return false;

	}			

	for( i=0;i<h;i++)

	{

		z = x.substring(i,i+1);

		if ( z=="'"||z=='"' || (z >= "a" && z <= "z" ) || (z >= "A" && z <= "Z") )

		{

			alert("Price Can be numeric only");

			return false;

		}			

	}

	jj=x.indexOf(".");

	if (jj != "-1") 

		{

		hh=x.substring(jj);

		ll=hh.length;

		if (ll > 3) 

			{

			alert("Price Can have upto 2 decimal places");

			return false;

			}

		}

	x = objName;

	return true;

	

}



function ValidateNumber(objName)

{

	//created on: 12th May 2002

	//Programmer: Naveen Sharma

	//Purpose	: This function is used to validate email. 

	//Arguments : Email object

		

	var h;

	var x;

	

	h=objName.length;

	x = objName;

	if (h==0)

	{

		alert("Price cannot be left blank");

		return false;

	}			

	for( i=0;i<h;i++)

	{

		z = x.substring(i,i+1);

		if ( z=="'"||z=='"' || (z >= "a" && z <= "z" ) || (z >= "A" && z <= "Z") )

		{

			alert("Price Can be numeric only");

			return false;

		}			

	}

	jj=x.indexOf(".");

	if (jj != "-1") 

		{

		hh=x.substring(jj);

		ll=hh.length;

		if (ll > 3) 

			{

			alert("Price Can have upto 2 decimal places");

			return false;

			}

		}

	return true;

	

}



function getFormattedmsg(sVal)

{

	while(sVal.indexOf("_")!=-1)

	{

		sVal = sVal.replace("_", " ")

	}

	return sVal;

	

}



// Function for cheking the proper Email ID while making login in Classified and Community section

	function valLoginForm(obj)

{



if(ValidateForm(obj))

	{

			if (ValidateEMail(obj.TR_Email_ID.value))

			{

				return true;

			}

			else

			{

				alert("Please enter Email ID in proper format");

				obj.TR_Email_ID.focus();

				return false;			

			}

	}

	return false;

}



function fnDetails(detailpage,iwidth,iheight)

{

	iLeft = parseInt(screen.width)/2-parseInt(iwidth)/2

	iTop = parseInt(screen.height)/2-parseInt(iheight)/2

	window.open(detailpage, "a", "toolbars=0, menubar=0, noresize, scrollbars=yes, left=" + iLeft + ",top=" + iTop + ", width=" + iwidth + ", height=" + iheight)

}





function valform(obj)

{

	

	if(ValidateForm(obj))

	{

			if (ValidateEMail(obj.TR_Email.value))

			{

				obj.submit()

				return true;

			}

			else

			{

				alert("Please enter Email in proper format")

				obj.TR_Email.select()

				return false;			

			}

	}

	return false;

}



	function keyvalid(){

			if(event.keyCode < 45 || event.keyCode > 57){ 

				event.returnValue = false;

			}	

			if(event.which < 45 || event.which > 57){ 

				return false;

			}

	}

	function redirect(opt){				

		if(opt==1){

			window.location="display_first.php";

		}else if(opt==2){

			window.location="billinfo.php";

		}else if(opt==3){

			window.location="historyview.php";

		}else if(opt==4){

			window.location="cart.php?cls=1";						

		}

	}

function addRowToTable()

{

  var tbl = document.getElementById('tblatributeID');

  var lastRow = tbl.rows.length;  

  // if there's no header row in the table, then iteration = lastRow + 1

  var iteration = lastRow;

  var row = tbl.insertRow(lastRow);  

  // left cell

  var cellLeft = row.insertCell(0);

  var textNode = document.createTextNode(iteration+'.');  

  cellLeft.setAttribute('align','center');    

  cellLeft.appendChild(textNode);

  

  var sizecell = row.insertCell(1);

  var el = document.createElement('input');

  el.setAttribute('type', 'text');



  el.setAttribute('name', 'psize[]');

  el.setAttribute('id', 'sizeid' + iteration);

  el.setAttribute('size', '20');

  el.setAttribute('class', 'inp');  

  sizecell.appendChild(el);



  var pricecell = row.insertCell(2);

  var el = document.createElement('input');

  el.setAttribute('type', 'text');

  el.setAttribute('name', 'pprice[]');

  el.setAttribute('id', 'priceid' + iteration);

  el.setAttribute('size', '10');  

  el.setAttribute('class', 'inp');

  el.onkeypress = keyvalid;

  pricecell.appendChild(el);



  var colorcell = row.insertCell(3);

  var el = document.createElement('input');

  el.setAttribute('type', 'text');

  el.setAttribute('name', 'pcolor[]');

  el.setAttribute('id', 'colorid' + iteration);

  el.setAttribute('size', '20');

  el.setAttribute('class', 'inp');  

  colorcell.appendChild(el);

}

function keyvalid(){

			if(event.keyCode < 45 || event.keyCode > 57){ 

				event.returnValue = false;

			}	

			if(event.which < 45 || event.which > 57){ 

				return false;

			}

}

function removeRowFromTable()

{

  var tbl = document.getElementById('tblatributeID');

  var lastRow = tbl.rows.length;

  if (lastRow > 2) tbl.deleteRow(lastRow - 1);

}



function validateRow()

{

    var tbl = document.getElementById('tblatributeID');

    var lastRow = tbl.rows.length - 1;

    var i;

    for (i=1; i<=lastRow; i++) {

		var txtSize = document.getElementById('sizeid' + i);

		var txtPrice = document.getElementById('priceid' + i);

		var txtColor = document.getElementById('colorid' + i);

		  if (txtSize.value.length <= 0 || txtPrice.value.length <= 0 || txtColor.value.length <= 0) {

			alert('Product attributes: -\n\nRow '+ i +' is not filled \nEach cell of row must be filled');

			document.getElementById('sizeid' + i).focus();

			return false;

		  }    

  	}

	return true; 

}



	function popwin(page){

		iLeft = parseInt(screen.width)/2-520/2

		iTop = parseInt(screen.height)/2-450/2

		window.open(page, "a", "toolbars=0, menubar=0, noresize, scrollbars=yes, left=" + iLeft + ",top=" + iTop + ", width=520, height=450")

	}

	function popwindow(url,wd,ht){

		iLeft = (parseInt(screen.width)/2) - (parseInt(wd)/2)

		iTop = (parseInt(screen.height)/2) - (parseInt(ht)/2)

		window.open(url, "a", "toolbars=0, menubar=0, noresize, scrollbars=yes, left=" + iLeft + ",top=" + iTop + ", width=" + wd + ", height=" + ht)

	}

function show_tbl(tbl_id){		

		document.getElementById(tbl_id).style.display='';		

}

function hide_tbl(tbl_id){				

		document.getElementById(tbl_id).style.display='none';

}

function hideshowtbl(show_tbl,hide_tbl){		

		document.getElementById(show_tbl).style.display='';

		document.getElementById(hide_tbl).style.display='none';

}

function full_screen_pop_up(theURL,windowname){

	window.open(theURL, windowname, ',type=fullWindow,fullscreen,scrollbars=yes');

}

function backtolist(url){

	window.location=url;

}