var maxChars = 1000;

function checkArea(objTextArea,isPaste){
	curLength = objTextArea.value.length
	if (curLength < maxChars){
		if (isPaste)
			if (maxChars-curLength-clipboardData.getData('Text').length<0)
				return false;
			else
				return true;
		else
			return true;
	}
	else
		return false;
}

function goNcheck1(theForm)
{
	
	if (theForm.ItemTitle.value == "")
	{
   	alert("Please enter Title");errorForm1();
	ItemTitleCaption.className = 'regtextCaption2';
   	theForm.ItemTitle.focus();return (false);
	}
	
	if (theForm.ItemDecsription.value == "")
	{
	alert("Please enter Description.");errorForm1();
	ItemDecsriptionCaption.className = 'regtextCaption2';
   	theForm.ItemDecsription.focus();return (false);
 	}
	
	if (theForm.ItemDecsription.value.length > 1000)
	{
	alert("Description field must not exceed 1000 characters.");errorForm1();
	ItemDecsriptionCaption.className = 'regtextCaption2';
   	theForm.ItemDecsription.focus();return (false);
 	}
	
	var valid="0123456789.,";
	var chk = 0;
	for (var i=0; i<theForm.ItemPrice.value.length; i++) if(valid.indexOf(theForm.ItemPrice.value.charAt(i)) == -1) chk++;
	numOfDot = 0;
	for (var i=0; i<theForm.ItemPrice.value.length; i++) if(theForm.ItemPrice.value.substring(i,i+1)==".") numOfDot++;
	if (numOfDot > 1) chk++;
	if (chk > 0)
	{
	alert("Please enter valid price in the Price field.");errorForm1();
	ItemPriceCaption.className = 'regtextCaption2';
   	theForm.ItemPrice.focus();return (false);
 	}
	
	valid="0123456789";
	chk = 0;
	for (var i=0; i<theForm.ItemQty.value.length; i++) if(valid.indexOf(theForm.ItemQty.value.charAt(i)) == -1) chk++;
	if (theForm.ItemQty.value < 1) chk++;
	if (chk > 0)
	{
	alert("Please enter only valid numbers in the Quantity field.");errorForm1();
	ItemQtyCaption.className = 'regtextCaption2';
   	theForm.ItemQty.focus();return (false);
 	}
	
	chk = 0;
	for (var i=0; i<theForm.ItemH.value.length; i++) if(valid.indexOf(theForm.ItemH.value.charAt(i)) == -1) chk++;
	if (chk > 0)
	{
	alert("Please enter only valid numbers in the Dimension fields.");errorForm1();
	ItemHCaption.className = 'regtextCaption2';
   	theForm.ItemH.focus();return (false);
 	}
	
	chk = 0;
	for (var i=0; i<theForm.ItemW.value.length; i++) if(valid.indexOf(theForm.ItemW.value.charAt(i)) == -1) chk++;
	if (chk > 0)
	{
	alert("Please enter only valid numbers in the Dimension fields.");errorForm1();
	ItemWCaption.className = 'regtextCaption2';
   	theForm.ItemW.focus();return (false);
 	}
	
	chk = 0;
	for (var i=0; i<theForm.ItemD.value.length; i++) if(valid.indexOf(theForm.ItemD.value.charAt(i)) == -1) chk++;
	if (chk > 0)
	{
	alert("Please enter only valid numbers in the Dimension fields.");errorForm1();
	ItemDCaption.className = 'regtextCaption2';
   	theForm.ItemD.focus();return (false);
 	}
	
	if (theForm.ItemPrice.value == "") theForm.ItemPrice.value = '0';
	if (theForm.ItemQty.value == "") theForm.ItemQty.value = '0';
	updateForm.submit();
}
 
function errorForm1()
{
ItemTitleCaption.className = 'regtextCaption';
ItemDecsriptionCaption.className = 'regtextCaption';
ItemPriceCaption.className = 'regtextCaption';
ItemQtyCaption.className = 'regtextCaption';
ItemHCaption.className = 'regtextCaption';
ItemWCaption.className = 'regtextCaption';
ItemDCaption.className = 'regtextCaption';
}

function changePic(picName,maxWidth,maxHeight)
{
w = document.images[picName].width;
h = document.images[picName].height;
if (w > h)
	{
	if (w > maxWidth)
		{
		set = maxWidth - w;
		set = set *-1;
		perW = set * (100 / w);
		perH = h - (h * perW / 100);
		h = Math.round(perH);
		w = maxWidth;
		}
	}
else
	{
	if (h > maxHeight)
		{
		set = maxHeight - h;
		set = set *-1;
		perH = set * (100 / h);
		perW = w - (w * perH / 100);
		w = Math.round(perW);
		h = maxHeight;
		}
	}		
document.images[picName].width = w;
document.images[picName].height = h;
}

function chooseframe(frameNo)
{
framedata1.className = 'textfieldpic';
framedata2.className = 'textfieldpic';
framedata3.className = 'textfieldpic';
framedata4.className = 'textfieldpic';
framedata5.className = 'textfieldpic';
if (frameNo == 1)
	{
	delFunction.innerHTML='&nbsp;';
	framedata1.className = 'textfieldpic1';
	if (uploadFile.pic1.value != 'none1.gif') delFunction.innerHTML='<input type="button" name="nonePic" value="Delete Picture" class="textfield" onclick="location.href=\'xt_inventory.asp?seller='+seller+'&flag=add&step=41&update='+uploadFile.updateId.value+'\'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
	document.mainPic.src=uploadFile.picStat.value+uploadFile.pic1.value+'&maxWidth=148&maxHeight=148';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=1';
	press=1;
	}
if (frameNo == 2)
	{
	delFunction.innerHTML='&nbsp;';
	framedata2.className = 'textfieldpic1';
	if (uploadFile.pic2.value != 'none1.gif') delFunction.innerHTML='<input type="button" name="nonePic" value="Delete Picture" class="textfield" onclick="location.href=\'xt_inventory.asp?seller='+seller+'&flag=add&step=42&update='+uploadFile.updateId.value+'\'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
	document.mainPic.src=uploadFile.picStat.value+uploadFile.pic2.value+'&maxWidth=148&maxHeight=148';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=2';
	press=1;
	}
if (frameNo == 3)
	{
	delFunction.innerHTML='&nbsp;';
	framedata3.className = 'textfieldpic1';
	if (uploadFile.pic3.value != 'none1.gif') delFunction.innerHTML='<input type="button" name="nonePic" value="Delete Picture" class="textfield" onclick="location.href=\'xt_inventory.asp?seller='+seller+'&flag=add&step=43&update='+uploadFile.updateId.value+'\'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
	document.mainPic.src=uploadFile.picStat.value+uploadFile.pic3.value+'&maxWidth=148&maxHeight=148';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=3';
	press=1;
	}
if (frameNo == 4)
	{
	delFunction.innerHTML='&nbsp;';
	framedata4.className = 'textfieldpic1';
	if (uploadFile.pic4.value != 'none1.gif') delFunction.innerHTML='<input type="button" name="nonePic" value="Delete Picture" class="textfield" onclick="location.href=\'xt_inventory.asp?seller='+seller+'&flag=add&step=44&update='+uploadFile.updateId.value+'\'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
	document.mainPic.src=uploadFile.picStat.value+uploadFile.pic4.value+'&maxWidth=148&maxHeight=148';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=4';
	press=1;
	}
if (frameNo == 5)
	{
	delFunction.innerHTML='&nbsp;';
	framedata5.className = 'textfieldpic1';
	if (uploadFile.pic5.value != 'none1.gif') delFunction.innerHTML='<input type="button" name="nonePic" value="Delete Picture" class="textfield" onclick="location.href=\'xt_inventory.asp?seller='+seller+'&flag=add&step=45&update='+uploadFile.updateId.value+'\'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
	document.mainPic.src=uploadFile.picStat.value+uploadFile.pic5.value+'&maxWidth=148&maxHeight=148';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=5';
	press=1;
	}
}

function chooseframe2(frameNo)
{
framedata1.className = 'textfieldpic';
framedata2.className = 'textfieldpic';
framedata3.className = 'textfieldpic';
framedata4.className = 'textfieldpic';
framedata5.className = 'textfieldpic';
if (frameNo == 1)
	{
	framedata1.className = 'textfieldpic1';
	if (uploadFile.pic1.value != 'none1.gif') document.mainPic.src=uploadFile.picStat2.value+uploadFile.pic1.value+'&maxWidth=148&maxHeight=148';
	else document.mainPic.src='images/blank.gif';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=1';
	press=1;
	}
if (frameNo == 2)
	{
	framedata2.className = 'textfieldpic1';
	if (uploadFile.pic2.value != 'none1.gif') document.mainPic.src=uploadFile.picStat2.value+uploadFile.pic2.value+'&maxWidth=148&maxHeight=148';
	else document.mainPic.src='images/blank.gif';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=2';
	press=1;
	}
if (frameNo == 3)
	{
	framedata3.className = 'textfieldpic1';
	if (uploadFile.pic3.value != 'none1.gif') document.mainPic.src=uploadFile.picStat2.value+uploadFile.pic3.value+'&maxWidth=148&maxHeight=148';
	else document.mainPic.src='images/blank.gif';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=3';
	press=1;
	}
if (frameNo == 4)
	{
	framedata4.className = 'textfieldpic1';
	if (uploadFile.pic4.value != 'none1.gif') document.mainPic.src=uploadFile.picStat2.value+uploadFile.pic4.value+'&maxWidth=148&maxHeight=148';
	else document.mainPic.src='images/blank.gif';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=4';
	press=1;
	}
if (frameNo == 5)
	{
	framedata5.className = 'textfieldpic1';
	if (uploadFile.pic5.value != 'none1.gif') document.mainPic.src=uploadFile.picStat2.value+uploadFile.pic5.value+'&maxWidth=148&maxHeight=148';
	else document.mainPic.src='images/blank.gif';
	uploadFile.action=uploadFile.originalAction.value+'&formPic=5';
	press=1;
	}
}

function prevpic()
{
	if (press==2)
		{
		avigdor.src=PicPath+pic1+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		avigdorPrev.src='images/backGray.gif';
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=1&pic='+pic1+'\',\'enPic\',530,430);';
		}
	else if (press==3)
		{
		avigdor.src=PicPath+pic2+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=2&pic='+pic2+'\',\'enPic\',530,430);';
		}
	else if (press==4)
		{
		avigdor.src=PicPath+pic3+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=3&pic='+pic3+'\',\'enPic\',530,430);';
		}
	else if (press==5)
		{
		avigdor.src=PicPath+pic4+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=4&pic='+pic4+'\',\'enPic\',530,430);';
		}
}

function nextpic()
{
	if (press==1)
		{
		avigdor.src=PicPath+pic2+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=2&pic='+pic2+'\',\'enPic\',530,430);';
		}
	else if (press==2)
		{
		avigdor.src=PicPath+pic3+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=3&pic='+pic3+'\',\'enPic\',530,430);';
		}
	else if (press==3)
		{
		avigdor.src=PicPath+pic4+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=4&pic='+pic4+'\',\'enPic\',530,430);';
		}
	else if (press==4)
		{
		avigdor.src=PicPath+pic5+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic();';
		avigdorPrevLink.href='javascript:prevpic();';
		imageNo.innerText=press;
		avigdorNext.src='images/dotsGray.gif';
		picLink.href='javascript:more(\'enPic.asp?id='+itemId+'&num=5&pic='+pic5+'\',\'enPic\',530,430);';
		}
}

function prevpic2()
{
	if (press==2)
		{
		avigdor.src=PicPath1+pic1+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		avigdorPrev.src='images/backGray.gif';
		}
	else if (press==3)
		{
		avigdor.src=PicPath2+pic2+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		}
	else if (press==4)
		{
		avigdor.src=PicPath3+pic3+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		}
	else if (press==5)
		{
		avigdor.src=PicPath4+pic4+'&maxWidth=148&maxHeight=148';
		avigdorNext.src='images/dots.gif';
		press--;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) avigdorNext.src='images/dotsGray.gif';
		}
}

function nextpic2()
{
	if (press==1)
		{
		avigdor.src=PicPath2+pic2+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		}
	else if (press==2)
		{
		avigdor.src=PicPath3+pic3+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		}
	else if (press==3)
		{
		avigdor.src=PicPath4+pic4+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		if (press==totalImages) {avigdorNext.src='images/dotsGray.gif';avigdorNextLink.href='#';}
		}
	else if (press==4)
		{
		avigdor.src=PicPath5+pic5+'&maxWidth=148&maxHeight=148';
		avigdorPrev.src='images/back.gif';
		press++;
		avigdorNextLink.href='javascript:nextpic2();';
		avigdorPrevLink.href='javascript:prevpic2();';
		imageNo.innerText=press;
		avigdorNext.src='images/dotsGray.gif';
		}
}

