/*Script for Bookmark*/
function addbookmark()
{
	var i = navigator.userAgent.indexOf("Netscape");
	if(i >= 0)
	{
		alert("Press Ctrl + D to Bookmark this Page");
	}
	else if (window.sidebar) // firefox
	{
		alert("Press Ctrl + D to bookmark");
	}
	else if(window.opera && window.print)
	{ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',"http://www.acedepot.com");
		elem.setAttribute('title',document.title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
	{
		window.external.AddFavorite("http://www.acedepot.com", 'www.acedepot.com - ' + document.title);
	}
	else
	{
		alert("Press Ctrl + D to Bookmark this page");
	}
}
/*Scripts for Newsletter*/
function nvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function nvalidate() 
{
	if (document.newsletter.semail.value.length==0) {
	alert("please enter your email address");
	document.newsletter.semail.focus();
	return false;
	}
	if(!nvalidateEmail(document.newsletter.semail.value)) {
		
	alert("please enter your valid email address"); 
	document.newsletter.semail.focus();
	return false; 
	}
	else document.newsletter.submit()
	return true;
}
/* Script for swapimage on item page */
function swapimage(val)
{

	for(i=0;i<=5;i++)
	{
		if(document.getElementById("morediv"+i))
		{
			if(i == val)
			{
				document.getElementById("morediv"+i).style.display = '';
					
			}
			else
			{
				document.getElementById("morediv"+i).style.display = 'none';
			}
		}		
	}
}
/*Script for Tellafriend*/
function tellreset() 
{
	document.tellafriend.name.value="";
	document.tellafriend.email.value="";
	document.tellafriend.friendmail1.value="";
	document.tellafriend.friendmail2.value="";
	document.tellafriend.friendmail3.value="";
}
function tellvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function tellvalidate() 
{
if (document.tellafriend.name.value.length==0) {
alert("please enter your name");
document.tellafriend.name.focus();
return false;
}
if (document.tellafriend.email.value.length==0) {
alert("please enter your email address");
document.tellafriend.email.focus();
return false;
}
if(!tellvalidateEmail(document.tellafriend.email.value)) 
               { 
                 alert("please enter your valid email address"); 
				 document.tellafriend.email.focus();
                 return false; 
               }
if (document.tellafriend.friendmail1.value.length==0 && document.tellafriend.friendmail2.value.length==0 && document.tellafriend.friendmail3.value.length==0) {
alert("please enter your friend's email address");
document.tellafriend.friendmail1.focus();
return false;
}
if (!(document.tellafriend.friendmail1.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail1.value)) 
               { 
                 alert("please enter your valid email address of 'email-1'");
				 document.tellafriend.friendmail1.focus();
                 return false; 
               }
}	   
if (!(document.tellafriend.friendmail2.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail2.value)) 
               { 
                 alert("please enter valid email address of 'email-2'"); 
				 document.tellafriend.friendmail2.focus();
                 return false; 
               }
}	   
if (!(document.tellafriend.friendmail3.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail3.value)) 
               { 
                 alert("please enter valid email address of 'email-3'"); 
				 document.tellafriend.friendmail3.focus();
                 return false; 
               }
}	
document.tellafriend.submit()
return false;
}
/*Script for Refer a Friend*/
function reset() 
{
	document.referafriend.name.value="";
	document.referafriend.email.value="";
	document.referafriend.friendmail1.value="";
	document.referafriend.friendmail2.value="";
	document.referafriend.friendmail3.value="";
}
function refervalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }
      return true;
    }
	return false;
}
function refervalidate() 
{
	if (document.referafriend.name.value.length==0) 
		{
		alert("please enter your name");
		document.referafriend.name.focus();
		return false;
		}
	if (document.referafriend.email.value.length==0) 
		{
		alert("please enter your email address");
		document.referafriend.email.focus();
		return false;
		}
	if(!refervalidateEmail(document.referafriend.email.value)) 
		{ 
		alert("please enter your valid email address"); 
		document.referafriend.email.focus();
		return false; 
		}
	if (document.referafriend.friendmail1.value.length==0 && document.referafriend.friendmail2.value.length==0 && document.referafriend.friendmail3.value.length==0) 
		{
		alert("please enter your friend's email address");
		document.referafriend.friendmail1.focus();
		return false;
		}
	
	if (!(document.referafriend.friendmail1.value.length==0))
		{		
		if(!refervalidateEmail(document.referafriend.friendmail1.value)) 
			{ 
				alert("please enter your valid email address of 'email-1'"); 
				document.referafriend.friendmail1.focus();
				return false; 
			}
		}	   
	if (!(document.referafriend.friendmail2.value.length==0))
	{		
		if(!refervalidateEmail(document.referafriend.friendmail2.value)) 
			{ 
				alert("please enter valid email address of 'email-2'");
				document.referafriend.friendmail2.focus();
				return false; 
			}
	}	   
	
	if (!(document.referafriend.friendmail3.value.length==0))
	{
		if(!refervalidateEmail(document.referafriend.friendmail3.value))
		{
			alert("please enter valid email address of 'email-3'"); 
			document.referafriend.friendmail3.focus();
			return false; 
		}
	}
	document.referafriend.submit()
return true;
}
/*Script for image scrolling*/
function rotatenext()
{
	
	str = '';
	last = scrstarpos + 5;
	
	if(last  > visdiv)
	{
		last =  visdiv;
	}
	cnt = 0;
		
	for(i=scrstarpos+1;i<=last;i++)
	{
		if(document.getElementById("morediv"+i))
		{			
			str = str + document.getElementById("morediv"+i).innerHTML;
			cnt++;
		}
	}
	scrstarpos=scrstarpos + 1;
	scrend=last;
	if(scrstarpos>visdiv)
	{
		scrstarpos=1;
	}
	y=1;
	for(i=cnt;i<5;i++)
	{
		if(document.getElementById("morediv"+y))
		{
 			str = str + document.getElementById("morediv"+y).innerHTML;
			scrend=y;
			y++;
		}
	}	
	document.getElementById('main').innerHTML=str;	
}
function rotateprev()
{
	str="";
	scrstarpos = scrstarpos - 1;
	if(scrstarpos == 0)
	{
		scrstarpos = visdiv;
	}
	count = 0;
	last = scrstarpos + 4;
	if(last > visdiv)
	{
		last = visdiv;
	}
	for(i=scrstarpos;i<=last;i++)
	{
		if(document.getElementById("morediv"+i))
		{
			str = str + document.getElementById("morediv"+i).innerHTML;
			count++;
		}
	}
	for(i=count, j=1;i<5;i++)
	{
		if(document.getElementById("morediv"+j))
		{
			str = str + document.getElementById("morediv"+j).innerHTML;
		}
		j++;
	}
	document.getElementById('main').innerHTML=str;	
}
/*Script for Reqeust A Call Back*/
function callbackreset() 
{
	document.callback.name.value="";
	document.callback.email.value="";
	document.callback.callbacknumber.value="";
	document.callback.interestarea.value="";
	document.callback.subject.value="";
}
function callbackvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function callbackvalidate() 
{
	if (document.callback.name.value.length==0) 
	{
		alert("please enter your name");
		document.callback.name.focus();
		return false;
	}
	
	if (document.callback.callbacknumber.value.length==0) 
	{
		alert("please enter your phone number");
		document.callback.callbacknumber.focus();
		return false;
	}
	
	if (document.callback.email.value.length==0) 
	{
		alert("please enter your email address");
		document.callback.email.focus();
		return false;
	}

	if(!callbackvalidateEmail(document.callback.email.value)) 
	{
		alert("please enter your valid email address"); 
		document.callback.email.focus();
		return false; 
	}
document.callback.submit()
return false;
}

/*Script for change option of protect purchase*/
function updatepurchase(selectid, selectindex)
{
	if(document.getElementById(selectid))
	{
		document.getElementById(selectid).selectedIndex = selectindex;
	}
}
/**/

/*Script for Recently view*/
var str1="Recent_LFE";

var newid = new Array();

var newmargin = new Array();

var newname = new Array();

var newprice = new Array();

var newsaleprice = new Array();

var neworderable = new Array();

var newimgpath = new Array();

var price = '';


function createCookieRV(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function GetCookieRV(name) 
{  
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function checkCookie(id, name, imgpath,  price)
{
	var i,count;
	totalcookie = GetCookieRV("Total_LFE");
	if(totalcookie != null)
	{
		i = Number(totalcookie);
		count=0;
		for(j=1;j<=i;j++)
		{
			username = GetCookieRV(str1 + j + "_id");
			if(username == id)
			{
				count++;
					
			}
		}

		if(count == 0)
		{
			if(i == 5)
			{
				for(m=1;m<=5;m++)
				{
					username=GetCookieRV(str1 + m);
					newname[newname.length] = username;

					str=str1+m;
					str=str+"_price";
					username = GetCookieRV(str);
					newprice[newprice.length] = username;

					str=str1+m;
					str=str+"_id";
					username = GetCookieRV(str); 
					newid[newid.length] = username;
			
					str=str1+m;
					str=str+"_imgpath";
					username = GetCookieRV(str); 
					newimgpath[newimgpath.length] = username;
				}

				for(m=1, n=1;m<5;m++, n++)
				{
					createCookieRV(str1+m, newname[n]);
					str=str1+m;
					str=str+"_id";
					createCookieRV(str,newid[n]);

					str=str1+m;
					str=str+"_imgpath";
					createCookieRV(str,newimgpath[n]);

					str=str1+m;
					str=str+"_price";
					createCookieRV(str,newprice[n]);
				}
				cookie_store(m, id, name, imgpath,  price);
			}
			else
			{
				i++;
				createCookieRV("Total_LFE",i);
				cookie_store(i, id, name, imgpath,  price);
			}
		}
	}
	else
	{
			i=1;
			createCookieRV("Total_LFE",i);
			cookie_store(i, id, name, imgpath,  price);
	}
}

function gc1()
{
	var i;
	totalcookie = GetCookieRV("Total_LFE");

	if(Number(totalcookie) > 1)
	{
		document.getElementById("recentdiv").style.display = "";
		document.getElementById("recent_title").style.display = "";
		//document.getElementById("seperator").style.display = '';
		i = Number(totalcookie) - 1;
		newcount = 1;

		var ihtml = "";
		for(j = i; j > 0; j--)
		{
			id = GetCookieRV(str1 + j + "_id");
			name = GetCookieRV(str1 + j);
			imgpath = GetCookieRV(str1 + j + "_imgpath");
			price = GetCookieRV(str1 + j + "_price");

			str=str1;
			str=str+j;
			str=str+'_id';
			lp =GetCookieRV(str); 	

			str=str1;
			str=str+j;
			str=str+'_id';
			lp =GetCookieRV(str); 

			ihtml += "<div class='recently-viewed-fp-pro'>";

			ihtml += "<div class='recently-viewed-fp-box'><div class='img-center'><a href='" + lp + ".html'><img src='" + imgpath + "' border='0' alt='" + name + "'></a></div></div>";
	var saleprice = parseFloat(price);
			ihtml += "<div class='related-items-fp-pro-text'><h2><a  title='" + name + "' alt='" + name + "' class='' href='" + lp + "'>" + name + "</h2></a><div class='recently-viewed-sale-price'>Sale Price: <span>$" + saleprice.toFixed(2) + "</span> <a href='" + id + ".html'><img src='http://98.129.37.252/stores/SharpChoiceOnline/images/view-more.png' alt='View More' title='View More' border='0' class='img-right'></a></div></div>";




//			ihtml += "<div class='related-items-fp-pro-text'><h2><a  title='" + name + "' class='' href='" + lp + "'>" + name + "</h2></a></div>";
//
	//		var saleprice = parseFloat(price);

	//		ihtml += "<div class='recently-viewed-price'>Price: <span>$" + saleprice.toFixed(2) + "</span></div>";
	
		//	ihtml += "<a href='+" + lp + "' title='" + name + "'><img src='http://98.129.37.252/stores/SharpChoiceOnline/images/view-more.png' alt='View More' title='View More' border='0' class='img-right'></a>";

			ihtml += '</div>';
		}
		document.getElementById("recentdiv").innerHTML = ihtml;
	}
}

function cookie_store(val, id, name, imgpath, price)
{
	createCookieRV(str1+val,name);
	str=str1+val;
	str=str+"_price";
	
	createCookieRV(str,price);
	str=str1+val;
	str=str+"_id";
	
	createCookieRV(str,id);
	str=str1+val;
	str=str+"_imgpath";
	createCookieRV(str,imgpath);
}

function del_cookie(name) {
document.cookie = name +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
/**/

/*Script for Tell a friend */
function tellvalidateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function tellvalidate()
{
if (document.tellafriend.name.value.length==0) {
alert("please enter your name");
document.tellafriend.name.focus();
return false;
}
if (document.tellafriend.email.value.length==0) {
alert("please enter your email address");
document.tellafriend.email.focus();
return false;
}
if(!tellvalidateEmail(document.tellafriend.email.value)) 
               { 
                 alert("please enter your valid email address"); 
				 document.tellafriend.email.focus();
                 return false; 
               }
if (document.tellafriend.friendmail1.value.length==0 && document.tellafriend.friendmail2.value.length==0 && document.tellafriend.friendmail3.value.length==0) {
alert("please enter your friend's email address");
document.tellafriend.friendmail1.focus();
return false;
}
if (!(document.tellafriend.friendmail1.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail1.value)) 
               { 
                 alert("please enter your valid email address of 'email-1'");
				 document.tellafriend.friendmail1.focus();
                 return false; 
               }
}	   
if (!(document.tellafriend.friendmail2.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail2.value)) 
               { 
                 alert("please enter valid email address of 'email-2'"); 
				 document.tellafriend.friendmail2.focus();
                 return false; 
               }
}	   
if (!(document.tellafriend.friendmail3.value.length==0)){		
if(!tellvalidateEmail(document.tellafriend.friendmail3.value)) 
               { 
                 alert("please enter valid email address of 'email-3'"); 
				 document.tellafriend.friendmail3.focus();
                 return false; 
               }
}	
document.tellafriend.submit()
return false;
}
/**/

function showengrav(val)
{
	if(val == "Yes")
	{
		document.getElementById("engr-id").style.display = '';
		if(document.getElementById("qty-dis"))
			document.getElementById("qty-dis").style.display = 'none';
		document.getElementById("qtybox").disabled = true;
	}
	else
	{
		document.getElementById("engr-id").style.display = 'none';
		document.getElementById("qty-dis").style.display = '';
		document.getElementById("qtybox").disabled = false;
	}
}
function showengravwdcase(val)
{
	if(val == "Yes")
	{
		document.getElementById("wdcaseengr-id").style.display = '';
	}
	else
	{
		document.getElementById("wdcaseengr-id").style.display = 'none';
	}
}
function addElement() {

 var ni = document.getElementById('mydiv');
 var numi = document.getElementById('thevalue');
 var num = (document.getElementById('thevalue').value - 1) + 2;
 numi.value = num;
 var newdiv = document.createElement('div');
 var intid = "<input type='hidden' name='vwitem" + num + "' value='" + pid + "'>";
 var divIdName = 'my'+num+'Div';
 newdiv.setAttribute('id',divIdName);
 disp1 = disp;
 i = disp1.indexOf('divno');
  while(i>=0)
  {
  	disp1 = disp1.replace('divno',num);
	i = disp1.indexOf('divno');
  }	
//	disp1 = disp1.replace('INNAME',"vwattr"+num+"_"+hexstring);
  newdiv.innerHTML = intid + disp1;
  ni.appendChild(newdiv);
}

function removeElement(divNum) {
  var d = document.getElementById('mydiv');
  divIdName = 'my'+divNum+'Div';
  var olddiv = document.getElementById(divIdName);
  d.removeChild(olddiv);
}

var popWin=null
var winCount=0
var winName="popWin"
function openPopWin(winURL,winWidth,winHeight,winFeatures,winLeft,winTop){var d_winLeft=20
var d_winTop=20
winName="popWin"+winCount++
closePopWin()
if(openPopWin.arguments.length>=4)
winFeatures=","+winFeatures
else
winFeatures=""
if(openPopWin.arguments.length==6)
winFeatures+=getLocation(winWidth,winHeight,winLeft,winTop)
else
winFeatures+=getLocation(winWidth,winHeight,d_winLeft,d_winTop)
popWin=window.open(winURL,winName,"width="+winWidth
+",height="+winHeight+winFeatures)}
function closePopWin(){if(navigator.appName!="Microsoft Internet Explorer"||parseInt(navigator.appVersion)>=4)
if(popWin!=null)if(!popWin.closed)popWin.close()}
function getLocation(winWidth,winHeight,winLeft,winTop){return""}
function getLocation(winWidth,winHeight,winLeft,winTop){var winLocation=""
if(winLeft<0)
winLeft=screen.width-winWidth+winLeft
if(winTop<0)
winTop=screen.height-winHeight+winTop
if(winTop=="cen")
winTop=(screen.height-winHeight)/2-20
if(winLeft=="cen")
winLeft=(screen.width-winWidth)/2
if(winLeft>0&winTop>0)
winLocation=",screenX="+winLeft+",left="+winLeft
+",screenY="+winTop+",top="+winTop
else
winLocation=""
return winLocation}
