// reserved: $asimAr, img, item, $loc, $qs, $que, scroll, smImg, $spAr, url, $win;
var navLok ='';
var $lock  ='';
var p="images/nav/"; // Default Image Path.

if (document.getElementById) {
		ecma= 1;
	} else if (document.all) {
		ie= 1;
	} else {
		n= 1;
	}


var dateTime=new Date();
var year=dateTime.getYear();
if (year<1900){
	year+=1900;
}


// open and write to a new document window//
function openWin(url,prodImg,cat,name,ww,wh,scroll) {
	var $win = window.open(url,cat,'width='+ ww +',height='+ wh +',scrollbars='+scroll);
	if (prodImg != '0') {
		$win.document.writeln('<html><head><title>Basic French: '+ cat +' - '+ name +'</title></head><body bgcolor=\"white\" marginwidth=0 marginheight=0 topmargin=0 leftmargin=0><img src=\"'+ prodImg +'\" /></body></html>');
		$win.document.close();
	}
	$win.focus();
}


// read variables from the Query String //
function loaded() {
/*		if (location.href.indexOf('?') != -1) {
		var $loc = location.href;
		var $que = $loc.indexOf('?');
		var $qs= $loc.substring($que+1,$loc.length);
			 $qs = $qs.replace(/=/gi,'=\"');

		if ($qs.indexOf('&') != -1){
			var $spAr = $qs.split('&');

			for (i=0; i<$spAr.length; i++ ) {
				$spAr[i] += '\"';
				eval($spAr[i]);
			}
		}else{
			$qs += '\"';
			eval($qs); alert(item);
		}
	}*/

// Sticky main nav buttons respective to the current category //
	if ($lock != (void 0)) {
		switch ($lock) {
		case 'new':
			flipImg('new_arrivals','On');
			navLok ='new_arrivals';
			break;
		case 'vintage':
			flipImg('vintage','On');
			navLok ='vintage';
			break;
		case 'housewares':
			flipImg('housewares','On');
			navLok ='housewares';
			break;
		case 'pantry':
			flipImg('pantry','On');
			navLok ='pantry';
			break;
		case 'linens':
			flipImg('linens','On');
			navLok ='linens';
			break;
		case 'tees':
			flipImg('t-shirts','On');
			navLok ='tees';
			break;
		case 'adults':
			flipImg('adults','On');
			navLok ='adults';
			break;
		case 'kids':
			flipImg('children_toys','On');
			navLok ='kids';
			break;
		case 'children':
			flipImg('children','On');
			navLok ='children';
			break;
		case 'toys':
			flipImg('toys','On');
			navLok ='toys';
			break;
		case 'toiletries':
			flipImg('toiletries','On');
			navLok ='toiletries';
			break;
		case 'soap':
			flipImg('soap','On');
			navLok ='soap';
			break;
		case 'beauty':
			flipImg('beauty','On');
			navLok ='beauty';
			break;
		case 'books':
			flipImg('stationery_books','On');
			navLok ='stationery_books';
			break;
		case 'clearance':
			flipImg('clearance','On');
			navLok ='clearance';
			break;
		case 'about':
			flipImg('about','On');
			navLok ='about';
			// Open a pop up window : from the Function above			
			void openWin('objcAd.htm','0','miniAd','0','445','90','0')
			break;
		case 'contact':
			flipImg('contact','On');
			navLok ='contact';
			break;
		case 'storelocator':
			flipImg('location','On');
			navLok ='location';
			break;
		default:
			break;
		}
	}

	// Link associations & Pop Ups
	var $d =document;

	if ($d.getElementById && $d.getElementById('checkout_new_address_link1')){
		$d.getElementById('checkout_new_address_link1').onclick= function(){openWin(this.href,0,'Reporting Codes',0,400,600,'yes'); return false;}
		$d.getElementById('checkout_new_address_link1').title ="POP UP WINDOW";
	}

   // MHDY pop up
   if (document.getElementById('policyPop')){
     document.getElementById('policyPop').onclick =function() {window.open(this.href,'poli'); return false;}
     document.getElementById('policyPop').title ='POP UP WINDOW';
   }
}

// preload main nav //
function preloadImg(){
	var imgExt="_On.gif"
	var ba=new Array('about','contact','location','housewares','linens','adults','children','toys','toiletries','stationery_books','clearance');
	var bal=ba.length;
	var bPreload=new Array();
	for (z=0;z<bal;z++){
		bPreload[z]=new Image();
		bPreload[z].src=p+ba[z]+imgExt;
	}
}

// XO for the main navigation //
function flipImg(name,state,$p){
	if (navLok != name) {
		if(!$p) $p=p; // allow $p to be set at a local level, otherwise, use the path declared above.
		document.images[name].src=$p+name+'_'+state+'.gif';
	}
}

// XO for the category mini nav //
function smFlip(name,smImg){
	document.images[name].src='images/french_products/sImg/'+ smImg + 's.gif';
}



function sendForm() {
if (document.contactInfo1.firstname.value=='') {
	alert('Please Enter Your First Name');
	return false;
} else if (document.contactInfo1.lastname.value=='') {
	alert('Please Enter Your Last Name');
	return false;
} else if (document.contactInfo1.address.value=='') {
	alert('Please Enter Your Address');
	return false;
} else if (document.contactInfo1.city.value=='') {
	alert('Please Enter Your City');
	return false;
} else if (document.contactInfo1.state.value=='') {
	alert('Please Enter Your State');
	return false;
} else if (document.contactInfo1.country.value=='') {
	alert('Please Enter Your Country');
	return false;
} else if (document.contactInfo1.phone.value==''){
	alert('Please Enter Your Phone Number');
	return false;
} else if((document.contactInfo1.email.value.indexOf('@')==-1) && (document.contactInfo1.email.value.indexOf('.')==-1)) {
	alert('Please use a valid e-mail address'); 
	return false;
} else {
	if (document.contactInfo1.list[1].checked == true) {
		document.contactInfo1.ml.value = "NO";
	} else {
		document.contactInfo1.ml.value = "Yes";
	}
	document.contactInfo1.method="POST";
	document.contactInfo1.action="em.php";
	return true;
}
}

function sendFormWholesale() {
if (document.contactInfo1.firstname.value=='') {
	alert('Please Enter Your First Name');
	return false;
} else if (document.contactInfo1.lastname.value=='') {
	alert('Please Enter Your Last Name');
	return false;
} else if (document.contactInfo1.address.value=='') {
	alert('Please Enter Your Address');
	return false;
} else if (document.contactInfo1.city.value=='') {
	alert('Please Enter Your City');
	return false;
} else if (document.contactInfo1.state.value=='') {
	alert('Please Enter Your State');
	return false;
} else if (document.contactInfo1.country.value=='') {
	alert('Please Enter Your Country');
	return false;
} else if (document.contactInfo1.phone.value==''){
	alert('Please Enter Your Phone Number');
	return false;
} else if((document.contactInfo1.email.value.indexOf('@')==-1) && (document.contactInfo1.email.value.indexOf('.')==-1)) {
	alert('Please use a valid e-mail address'); 
	return false;
} else {
	if (document.contactInfo1.list[1].checked == true) {
		document.contactInfo1.ml.value = "NO";
	} else {
		document.contactInfo1.ml.value = "Yes";
	}
	document.contactInfo1.method="POST";
	document.contactInfo1.action="em.wholesale.php";
	return true;
}
}

// Onload Event
if (document.getElementById){
	window.onload =loaded;
}
