﻿
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImageOver(image, obj) {
	obj.src = "image/" + image;
}
function swapImageOut(image, obj) {
	obj.src = "image/" + image;
}
function validate_searchItem() {
	if (document.searchItemForm.searchItem.value.length == 0) {
		alert("Type the keyword to search.");
		document.searchItemForm.searchItem.focus();
		return(false);
	}
}
function validate_newsLetter() {
	if (document.newsLetter.email.value.length == 0) {
		alert("Please type your valid email address.");
		document.newsLetter.email.focus();
		return(false);
	}
	apos = document.newsLetter.email.value.indexOf("@");
	dotpos = document.newsLetter.email.value.indexOf(".");
	lastpos = document.newsLetter.email.value.length-1;
	if (apos<1 || lastpos-dotpos<2) {
		alert("Please type your email address in correct format.");
		document.newsLetter.email.focus();
		return(false);		
	} 
	return(true);
}
function confirmExit() {
	if (confirm("Are you sure you want to Sign Off?")){
		window.location.href = "https://www.uneetee.com/secure/signOut/signOut.asp";
	}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*function changeSizeModule(obj){
	alert(obj.value);
	if (obj.value == "men"){
		document.getElementById("menSizes").style.visibilty = "visible"; 
		document.getElementById("womenSizes").style.visibilty = "hidden"; 
	}else {
		eval("menSizes").style.visibilty = "hidden"; 
		eval("womenSizes").style.visibility = "visible";
	}
}*/
function getHTTPObject() {
var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	xmlhttp = false;
	}
	}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}
var isWorking = false;
var http = getHTTPObject();
function changeSizeModule(obj){
	designId = document.prodInfoForm.designId.value;
		url="ajaxGetSizeChoices.asp?currVal=" + obj.value + "&designId=" + designId;
		if (!isWorking) {
			http.open("GET", url, true);
			isWorking = true;
			http.onreadystatechange = function(){
				if (http.readyState == 4) {
					isWorking = false;
					if (http.responseText.indexOf('invalid') == -1) {
						isWorking = false;
					}
					processSizeOut(http.responseText);
				}
			}
			http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
			http.send(null);				
		}
}
function processSizeOut(str){
	if (str != ""){
		str = new String(str);
		arrStr = str.split(";");
		if (arrStr[0] == null){
			arrStr[0] = str;
		}
		for (i=0;i<arrStr.length;i++){
			strOfArr = arrStr[i];
			strOfArr = new String(strOfArr);
			arrStrOfArr = strOfArr.split(":");
			document.getElementById("size").options.length = arrStr.length;
			document.getElementById("size").options[i].value = arrStrOfArr[0];
			document.getElementById("size").options[i].text = arrStrOfArr[1];
		}
	}
}
function swapImage(str,design_fileName){
	document.getElementById("prodImg").src = "designImages/" + str + "_" + design_fileName;
}


function swapImage(picture, when){
	document.getElementById("frontImage" + when).src = "designImages/" + picture;
}
function swapImageOnly(pictureName) {
	document.getElementById("frontImage").src = "designImages/" + pictureName;
}
function zoomFP(dId, index){
	gender = document.getElementById("d_gender" + index).value
	page = "main_zoom.asp?designId=" +dId+ "&gender=" + gender;
	OpenWin = this.open(page, "zoom", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=470,height=520,left=0,top=0");
	OpenWin.focus();
}
function changeGender(gender, when){
	document.getElementById("d_gender" + when).value = gender;
}
function zoomArt(filename){
	page = "zoomArt.asp?file=" + filename;
	OpenWin = this.open(page, "zoom", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=500,height=357,left=0,top=0");
	OpenWin.focus();
}
function call_dispFeaturedArtis(){
	hyp_featured.className = "featured_sold_on";
	hyp_sold.className = "featured_sold";
	tab_featured_sold2.className = "right_hover_off";
	tab_featured_sold1.className = "border_leftRightTop_black_on";
	getFeaturedArtistModule();
}
function getFeaturedArtistModule(){
	url="ajaxFeaturedArtist.asp";
	if (!isWorking) {
		http.open("GET", url, true);
		isWorking = true;
		http.onreadystatechange = function(){
			if (http.readyState == 4) {
				isWorking = false;
				if (http.responseText.indexOf('invalid') == -1) {
					isWorking = false;
				}
				td_feat_sold_content.innerHTML = http.responseText;
			}
		}
		http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		http.send(null);				
	}
}
function call_dispSoldOut(){
	/*hyp_sold.className = "featured_sold_on";
	hyp_featured.className = "featured_sold";
	tab_featured_sold2.className = "right_hover_on";
	tab_featured_sold1.className = "border_leftRightTop_black_off";
	getSoldOutModule();*/
}
function getSoldOutModule(){
/*	url="ajaxSoldOutInfo.asp";
	if (!isWorking) {
		http.open("GET", url, true);
		isWorking = true;
		http.onreadystatechange = function(){
			if (http.readyState == 4) {
				isWorking = false;
				if (http.responseText.indexOf('invalid') == -1) {
					isWorking = false;
				}
				td_feat_sold_content.innerHTML = http.responseText;
			}
		}
		http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		http.send(null);				
	}*/
}
function tellAFriend(){
	var c = getAnchorPosition("a_tellAFriend");
	document.getElementById("div_tellAFriend").style.top = c.y + 13;
	document.getElementById("div_tellAFriend").style.left = c.x;
	document.getElementById("div_tellAFriend").style.visibility = "visible";
}
function processTellAFriend(frPage){
	email=document.getElementById("txt_tellAfriend").value;
	isEmailValid = true;
	alertMsg = "";
	if (document.getElementById("txt_sender").value.length == 0) {
		isEmailValid = false;
		alertMsg = "Please type your name.";
	}
	if (document.getElementById("txt_email").value.length == 0) {
		isEmailValid = false;
		alertMsg = "Please type your email.";
	}
	if (document.getElementById("txt_email").value.length != 0){
		apos = document.getElementById("txt_email").value.indexOf("@");
		dotpos = document.getElementById("txt_email").value.indexOf(".");
		lastpos = document.getElementById("txt_email").value.length-1;
		if (apos<1 || lastpos-dotpos<2) {
			isEmailValid = false;
			if (alertMsg == ""){
				alertMsg = "Please type your email";
			}
		} 
	}
	if (document.getElementById("txt_tellAfriend").value.length == 0) {
		isEmailValid = false;
		alertMsg = "Please type your friend's email.";
	}
	if (document.getElementById("txt_tellAfriend").value.length != 0){
		apos = document.getElementById("txt_tellAfriend").value.indexOf("@");
		dotpos = document.getElementById("txt_tellAfriend").value.indexOf(".");
		lastpos = document.getElementById("txt_tellAfriend").value.length-1;
		if (apos<1 || lastpos-dotpos<2) {
			isEmailValid = false;
			if (alertMsg == ""){
				alertMsg = "Please type your friend's email";
			}
		} 
	}
	if (isEmailValid){
		document.getElementById("div_tellAFriend").style.visibility = "hidden";
		url="ajaxEmailAFriend.asp?y_name=" + escape(document.getElementById("txt_sender").value) + "&f_email=" +document.getElementById("txt_tellAfriend").value + "&txt_email=" + document.getElementById("txt_email").value;
		//openNew(url);
		if (!isWorking) {
			http.open("GET", url, true);
			isWorking = true;
			http.onreadystatechange = function(){
				if (http.readyState == 4) {
					isWorking = false;
					if (http.responseText.indexOf('invalid') == -1) {
						isWorking = false;
					}
					processEmailFriend(http.responseText);
					//td_feat_sold_content.innerHTML = http.responseText;
				}
			}
			http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
			http.send(null);				
		}
	}else {
		alert(alertMsg);
	}
}
function openNew(url){
	OpenWin = this.open(url, "zoom", "toolbar=no,menubar=no,location=yes,scrollbars=yes,resizable=yes,width=470,height=520,left=0,top=0");
	OpenWin.focus();
}
function processEmailFriend(strTxt){
	var c = getAnchorPosition("a_tellAFriend");
	document.getElementById("div_bubDialog").style.top = c.y + 15;
	document.getElementById("div_bubDialog").style.left = c.x-51;
	document.getElementById("div_bubDialog").style.visibility = "visible";
	document.getElementById("bub_Content").innerHTML = strTxt;
	self.setTimeout("hideBubble()", 5000);
}
function hideBubble(){
	document.getElementById("div_bubDialog").style.visibility = "hidden";
}
function addMystery(){
	if (document.getElementById("sendDate").value.length == 0){
		alert("Please choose the date to ship the mystery gift to someone else.");
	}else {
		document.prodInfoForm.submit();
	}
}
function swapSizeImageMOver(objid, cartSize){
	imagename = cartSize + "_size";
	obj = document.getElementById(objid);
	obj.src = "image/" + imagename + "_ro.gif";
}

function swapSizeImageMOut(objid, sizeid, index, gen, cartSize) {
	imagename = cartSize + "_size";
	valGender = document.getElementById("gender").value;
	valSize = document.getElementById("size").value

	obj = document.getElementById(objid);
	if (sizeid == valSize && gen == valGender){
		
	}else {
		obj.src = "image/" + imagename + ".gif";
	}
}
function setSizeGen(objid, gen, size, index, cartSize) {
	resetAllSizes();
	imagename = cartSize + "_size";
	obj = document.getElementById(objid);
	obj.src = "image/" + imagename + "_ro.gif";
	document.getElementById("gender").value = gen;
	document.getElementById("size").value = size;
}
function promtLogout(url)
{
	if (confirm("Are you sure you want to log out?")){
		window.location.href = url;
	}
}

function resetAllSizes(){
	sizesIds = document.getElementById("sizesIds").value;
	arrSizes = sizesIds.split(",");
	for (i=0;i<sizesIds.length;i++) {
		obj = document.getElementById(arrSizes[i]);
		if (obj != null) {
			imagename = obj.id;
			//alert("obj.id = " + obj.id)
			imagename = imagename.replace("female_", "");
			imagename = imagename.replace("male_", "");
			imagename = imagename.replace("_1", "");
			imagename = imagename.replace("_2", "");
			//alert("imagename = " + imagename)
			obj.src = "image/" + imagename + ".gif";
		}else {
			break;
		}
	}
}
function assignDesignID(designID, uid){
	document.getElementById("designId").value = designID;
	document.getElementById("designUserId").value = uid;
}

function validatehomeproduct(){
	if (document.getElementById("designId") != null){
		if (document.getElementById("designId").value.length == 0) {
			alert("Please choose the design and/or size to buy.");
			return false;
		}
	}
	if (document.getElementById("gender") != null){
		if (document.getElementById("gender").value.length == 0) {
			alert("Please choose a size to buy.");
			return false;
		}
	}
	return true;
}
