/*

copyright 2011 zazou, inc


*/

/* Free code from dyn-web.com */

// Two choices for loading new pages into the iframe 

// dom0 frames referencing 
function loadIframe(iframeName, url) {
    if ( window.frames[iframeName] ) {
        window.frames[iframeName].location = url;   
        return false;
    }
    return true;
}

// assign new url to iframe element's src property
function changeIframeSrc(id, url) {
    if (!document.getElementById) return;
    var el = document.getElementById(id);
    if (el && el.src) {
        el.src = url;
        return false;
    }
    return true;
}


var _GET = new Array();
var u = location.search.substr(1);

if (u.length > 1) {

	t = u.split("&");

	for(i=0;i<t.length;i++) {
		vars = t[i].split("=");
		key = eval('"'+ vars[0] +'"');
		value = vars[1];
		_GET[key] = value;
	}
	
}

function stickrollo(){
	var menuimgs = new Array();
	if(document.images )
	{
		if(document.images[EscapeMenuS])
		{	
			document.images[EscapeMenuS].src = '/images/nav/'+ EscapeMenuS + '_on.gif';
		}

		if(document.images[EscapeMenu])
		{	
			document.images[EscapeMenu].src = '/images/nav/'+ EscapeMenu + '_on.gif';
		}
	}
}

function validate(f) {
	return true;
	
}


function rollOver(iName, iState) 
{
	if( EscapeMenu != iName && EscapeMenuS != iName )
	{
		if(document.images && self[iName + '_' + iState]) 
		{
    			document.images[iName].src = self[iName + '_' + iState].src;
		}
	}
	else
	{
		if(document.images && self[iName + '_' + iState]) 
		{
    			document.images[iName].src = self[iName + '_on'].src;
		}
	
	}
}

var iPath = '/images/nav/';
var iExt = 'gif';
var suffix = new Array('on', 'off');

function preLoad()
{
  if(document.images)
  {
    var argLen = arguments.length;
    for(var i = 0; i < argLen; i++)
    {
      var arg = arguments[i];
      var sufLen = suffix.length;
      for(j = 0; j < sufLen; j++)
      {
        var suf = suffix[j]
        self[arg + '_' + suf] = new Image();
        self[arg + '_' + suf].src = iPath + arg + '_' + suf + '.' + iExt;
      }
    }   
  }
}

/*function showaltimg(img1,img2,obj){
	
	var currimg = document.prodimg.src.split("/").pop();
	obj.innerHTML=(obj.innerHTML=='ALTERNATE VIEW')?'NORMAL VIEW':'ALTERNATE VIEW';
	if(document.prodimg) {
		document.prodimg.src = (currimg == img1) ? '/images/product/' + img2 : '/images/product/' + img1;
		
	}

}*/


function getObj(name) {

    if (document.getElementById) {
        this.obj = document.getElementById(name);
        this.style = document.getElementById(name).style;
    
    } else if (document.all) {
        this.obj = document.all[name];
        this.style = document.all[name].style;

    } else if (document.layers) {
        this.obj = document.layers[name];
        this.style = document.layers[name];
    }
}

function show_hide(divobj) {
    var x = new getObj(divobj);
    x.style.display = (x.style.display == 'block') ? 'none' : 'block';
}

function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

function joinmaillist(){
    var email = document.maillist.email.value;
    if(email==''){
        alert('Please enter your email address!');
        return false;
    }
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(email)){
          document.maillist.submit();
    }else{
          alert('Invalid Email Address!');
          return false;
    }
}

function wholesaleValid(){
    var login = document.wholesale.wholesalelogin1.value;
   var password = document.wholesale.wholesalepassword.value;
    
	if(login==''){
        alert('Please enter your wholesale login!');
        return false;
    }
	
	if(password==''){
        alert('Please enter your wholesale password!');
        return false;
    }
	
	
    if(login=='zebra'){
		if (password=='5tr1p35') {
		  alert('Welcome to the ZAZOU wholesale store. Please remember that all wholesale purchases must be greater than $200 and that we will verify your merchant ID.');
          return true;
		}else{
		  alert('Invalid Password!');
          return false;
		}
			  
    }else{
          alert('Invalid Login!');
          return false;
    }
}



function formValidatorWholesaleApp(theForm)
{
  if (theForm.storename.value == "")
  {
	alert("Store Name cannot be blank!");
	theForm.storename.focus();
	return (false);
  }
  if (theForm.contact.value == "")
  {
	alert("Contact cannot be blank!");
	theForm.contact.focus();
	return (false);
  }
  	if (theForm.resaleid.value == "")
  {
	alert("Reseller Permit No cannot be blank!");
	theForm.resaleid.focus();
	return (false);
  }
  	if (theForm.address1.value == "")
  {
	alert("Address cannot be blank!");
	theForm.address1.focus();
	return (false);
  }
	if (theForm.email.value == "")
	{
		alert("e-Mail Address cannot be blank!");
		theForm.email.focus();
		return (false);
	}

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(theForm.email.value))
	{
		alert("Invalid Email Address!");
		theForm.email.focus();
		return (false);
	}
  	if (theForm.phone.value == "")
  {
	alert("Phone cannot be blank!");
	theForm.phone.focus();
	return (false);
  }
   	if (theForm.merchandise.value == "")
  {
	alert("Merchandise cannot be blank!");
	theForm.merchandise.focus();
	return (false);
  }





  }


