var queue;
function changeImage( imagesrc, imageTag, imgwidth, imgheight )
{
	//var imagesrc=document.getElementById(imageID).src;
	if(queue!='')
	{
	    clearInterval(queue);
    }
    queue = setInterval(function () { updateImage( imagesrc, imageTag, imgwidth, imgheight ); },2000);
}
function changeImageCancel()
{
	//var imagesrc=document.getElementById(imageID).src;
	if(queue!='')
	{
        clearInterval(queue);
    }
}
function updateImage( imagesrc, imageTag, imgwidth, imgheight )
{
    if(queue!='')
    {
        clearInterval(queue);
    }
    queue = '';
	choiceDisplay("photos");
// 		document.getElementById('display_video').style.display='none';
// 		document.getElementById('display_photos').style.display='';
	imageObj = document.getElementById('showimage');
	imageObj.style.display='';
	imageObj.src='';
	imageObj.src=imagesrc;
	imageObj.title=imageTag;
	imageObj.setAttribute('width', imgwidth);
	imageObj.setAttribute('height', imgheight);
}
/*function showProVideo(imageID)
{
	var imagesrc=document.getElementById(imageID).src;
		choiceDisplay("video");
// 		document.getElementById('display_video').style.display='none';
// 		document.getElementById('display_photos').style.display='';
		document.getElementById('showimage').style.display='none';
		document.getElementById('showimage').src=imagesrc;
}*/
function showProVideo( imagesrc, imgwidth, imgheight )
{
	//var imagesrc=document.getElementById(imageID).src;
		choiceDisplay("video");
// 		document.getElementById('display_video').style.display='none';
// 		document.getElementById('display_photos').style.display='';
		document.getElementById('showimage').style.display='none';
		document.getElementById('showimage').src=imagesrc;
}

function choiceDisplay(display_type)
{
	if(display_type=="video"){
		document.getElementById("display_photos").style.display="none";
		document.getElementById("display_photos").className="product_image  displayNone";

		document.getElementById("display_video").style.display="";
		document.getElementById("display_video").className="product_image";
	}
	if(display_type=="photos"){
		document.getElementById("display_photos").style.display="";
		document.getElementById("display_photos").className="product_image";

		document.getElementById("display_video").style.display="none";
		document.getElementById("display_video").className="product_image displayNone";
	}
}
function currencyChange()
{
	document.getElementById("currencyform").submit;	
	//var currencyName=document.getElementById('currencyName').value;
	//return currencyName;
}

function change_form_action(val)
{
	if($("quantity").value == "")
	{
		alert("Please enter product quantity.");
		$("quantity").focus();
		return false;
	}
	else
	{		
		if(val == "add_cart")
		{
			$("add_cart_form").action = host+'cart/addtocart';
		}
		return true;
	}
}

/* function for address book */
function validateAddress()
{
	var char_format=/^[A-Za-z][A-Za-z ._-]*$/;
	var first_name=document.getElementById('fname').value;
	if(customer_required(first_name,'Please enter customer name.')==false)
	{
		$('fname').focus();
		$('fname').select();
		return false;
	}
	if (!(char_format.test(first_name)))
	{
		alert('Please enter valid customer name.');
		$('fname').focus();
		$('fname').select();
		return false;
	}

	var address=$('street_addr').value;
	if (address==null||address=="")
	{ 
		alert('Please enter address.'); 
		$('street_addr').focus();
		$('street_addr').select();
		return false; 
	}
	var post_format=/^[0-9]*$/;
	var cust_postcode=$('postalcode').value;
// 	if (cust_postcode==null||cust_postcode=="")
// 	{ 
// 		alert('Please enter post code.'); 
// 		$('postalcode').focus();
// 		$('postalcode').select();
// 		return false; 
// 	}
    if (cust_postcode!="")
 	{ 
       if (!(post_format.test(cust_postcode)))
       {
           alert('Please enter numeric value on post code field.');
           $('postalcode').focus();
           $('postalcode').select();
           return false;
       }
    }
	var city=$('city').value;
// 	if (city==null||city=="")
// 	{ 
// 		alert('Please enter city name.'); 
// 		$('city').focus();
// 		$('city').select();
// 		return false; 
// 	}
    if (city!="")
	{ 
       if (!(char_format.test(city)))
       {
           alert('Please enter valid city name.');
           $('city').focus();
           $('city').select();
           return false;
       }
    }
	var state=$('cust_state').value;
	if (state=="0")
	{ 
		alert('Please select a state.'); 
		$('cust_state').focus();
		$('cust_state').select();
		return false; 
	}


	else
	{
		return true;
	}	

}

function customer_required(field,alerttxt)
{ 
	if (field==null||field=="")
	{ 
		alert(alerttxt); 
		return false; 
	}
}

function validateJoinlist()
{
        
	var char_format=/^[A-Za-z][A-Za-z._ ]*$/;

	var first_name=document.getElementById('full_name').value;
         if(customer_required(first_name,'Please enter your full name.')==false)
	{
		$('full_name').focus();
		$('full_name').select();
		return false;
	}
	if (!(char_format.test(first_name)))
	{
		alert('Please enter only characters on full name.');
		$('full_name').focus();
		$('full_name').select();
		return false;
	}
	var email_format=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	var email=document.getElementById('email').value;
	if(customer_required(email,'Please enter your valid email.')==false)
	{
		$('email').focus();
		$('email').select();
		return false;
	}
	if (!(email_format.test(email)))
	{
		alert('Please enter valid email.');
		$('email').focus();
		$('email').select();
		return false;
	}
	var num_format=/^[0-9]*$/;
	var mobile=document.getElementById('mobile').value;
	if (mobile!="")
	{ 

		if (!(num_format.test(mobile)))
		{
			alert('Please enter numeric value on mobile number.');
			$('mobile').focus();
			$('mobile').select();
			return false;
		}
	}
	var telephone1=document.getElementById('telephone1').value;
	if (telephone1!="")
	{ 

		if (!(num_format.test(telephone1)))
		{
			alert('Please enter numeric value on telephone code.');
			$('telephone1').focus();
			$('telephone1').select();
			return false;
		}
	}
	var telephone2=document.getElementById('telephone2').value;
	if (telephone2!="")
	{ 
		if (!(num_format.test(telephone2)))
		{
			alert('Please enter numeric value on telephone code.');
			$('telephone2').focus();
			$('telephone2').select();
			return false;
		}
	}
	if(telephone1=="" && telephone2!="")
	{
		alert('Please enter telephone code.');
		$('telephone1').focus();
		$('telephone1').select();
		return false;
	}
	if(telephone1!="" && telephone2=="")
	{
		alert('Please enter telephone number.');
		$('telephone2').focus();
		$('telephone2').select();
		return false;
	}
	var security_code=document.getElementById('security_code').value;
         if(customer_required(security_code,'Please enter Security Code.')==false)
	{
		$('security_code').focus();
		$('security_code').select();
		return false;
	}
	else
	{
		return true;
	}
	
}

function showSubmenu(tempMainID,parentId,childId){
/*	if(document.getElementById('videoId')!=null){
		if(document.getElementById('display_video')!=null){
			document.getElementById('display_video').style.display="none";				
		}	
		document.getElementById('videoId').style.visibility="hidden";
	}	*/
	if(document.getElementById(tempMainID)!=null){
		if((document.getElementById(tempMainID).offsetLeft + 100) < document.getElementById(parentId).offsetLeft){
		document.getElementById(childId).style.marginLeft="0px";
	}else{

	}
	}
	if(document.getElementById('class_id').value != parentId){
		document.getElementById(parentId).className='cat_selected';
		document.getElementById(document.getElementById('class_id').value).className='';
	}
	document.getElementById(parentId).className='cat_selected';
	if(document.getElementById(childId)!=null){
		document.getElementById(childId).style.display="block";
	}
}
function hideSubmenu(parentId,childId){
	if(document.getElementById('videoId')!=null){
		if(document.getElementById('display_video')!=null){
			document.getElementById('display_video').style.display="";				
		}
		document.getElementById('videoId').style.visibility="visible";
	}
	document.getElementById(parentId).className='cat_current';
	if(document.getElementById('class_id').value == parentId){
		document.getElementById(parentId).className='cat_current';
	}else{
		if(document.getElementById(parentId)!=null){
		document.getElementById(parentId).className='cat_current';
		}
	}
	if(document.getElementById(childId)!=null){
	document.getElementById(childId).style.display="none";
	//document.getElementById(childId).style.display="block";
	}
	document.getElementById(document.getElementById('class_id').value).className='cat_current';	
}

function showInnermenu(parentId,childId){
	if(document.getElementById('class_id').value != parentId){
		document.getElementById(parentId).className='cat_selected';
		document.getElementById(document.getElementById('class_id').value).className='cat_current';
	}
	document.getElementById(parentId).className='cat_selected';
	if(document.getElementById(childId)!=null){
	document.getElementById(childId).style.display='block';	
	}
}
function hideInnermenu(parentId,childId){
	document.getElementById(parentId).className='cat_current';
	document.getElementById(childId).style.display='none';
	document.getElementById(document.getElementById('class_id').value).className='cat_current';		
}
function setClass(tempId){
	document.getElementById('class_id').value=tempId;
	document.getElementById(tempId).className='cat_selected';	
}
function calculateSubmenu(tempMainID,temp,parentId,childId){
	var widthX;
	//widthX=((temp*170)+10);	
	widthX = 230;
	document.getElementById(childId).style.width=widthX+"px";	
	if(document.getElementById(tempMainID)!=null){
		if((document.getElementById(tempMainID).offsetLeft + 100) < document.getElementById(parentId).offsetLeft){
			document.getElementById(childId).style.left=-(widthX+5)+"px";
		}else{
			document.getElementById(childId).style.left="0px";
		}
	}
}
function ignoreClick()
{return false;}

function disable1(){
        //alert("function.js");
        var x=document.getElementById("currencyName");
        x.disabled=true;	
        links=document.getElementsByTagName('a');
        inputlink=document.getElementsByTagName('input');
        linksli=document.getElementsByTagName('li');
        for(var i=0; i<links.length; i++) {
          links[i].href="javascript:void(0)";
		   links[i].target="";
		   }
       for(var i=0; i<inputlink.length; i++) {
         inputlink[i].disabled="disabled";
        }
        for(var i=0; i<linksli.length; i++) {
            linksli[i].onmouseout="";
           linksli[i].onmouseover="";

        }
           if(document.getElementById("gender")!=null)
	        {
              var x1=document.getElementById("gender");
               x1.disabled=true;
		   }
		    if(document.getElementById("country")!=null)
            {		 
	           var x2=document.getElementById("country");
               x2.disabled=true;
	        }
			if(document.getElementById("storepreview")!=null)
			 {
			   document.getElementById('storepreview').style.display="block";
			  }
			document.getElementById("testchat").onclick=ignoreClick;
			
			
   
}

