/*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("mainimage"+i))
		{
			if(i == val)
			{
				document.getElementById("mainimage"+i).style.display = '';
			}
			else
			{
				document.getElementById("mainimage"+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;
}