
// Flash and CSS init (c) Agents.se - v3.0

var flashver = deconcept.SWFObjectUtil.getPlayerVersion()['major'];

// CSS Browser Selector   v0.2.3
// Documentation:         http://rafael.adm.br/css_browser_selector
var css_browser_selector = function() {
	var 
		ua = navigator.userAgent.toLowerCase();
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
	var c = b+os+' js';
	h.className += h.className?' '+c:c;
}();

// Open window
var newWin = null;
function popMeUp(strURL,strType,strWidth,strHeight) {
	if (newWin != null){
		if(!newWin.closed) newWin.close();
	}
	var left=((window.screen.width/2)-(strWidth/2))-12;
	var top=((window.screen.height/2)-(strHeight/2));
	var strOptions="";
	if (strType=="console") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

// No spam e-mail address v2
function noSpam(a,b,c,d) {
	if (d==null) {
		d = c+'@'+b+'.'+a;
	}
	document.write('<a href="mai'+'lto:'+c+'@'+b+'.'+a+'">'+d+'</a>');
}

// Ajax Capable Browser?
var xmlHttp=null;
function GetXmlHttpObject() {
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

// Hide/Show 1 Div
function toggle(a) {
	b = document.getElementById(a).style;
	if (b.display=="none") {
		b.display="block";
	} else {
		b.display="none";
	}
	return false;
}

// Hide/Show 2+1 Divs
function toggle3(a) {    
	b = document.getElementById(a+"open").style;
	c = document.getElementById(a+"close").style;
	d = document.getElementById(a).style;
	if (b.display=="none") {
		e = "close"
		b.display="block";
		c.display="none";
		d.display="none";
	} else {
		e = "open"
		b.display="none";
		c.display="block";
		d.display="block";
	}
	xmlHttp=GetXmlHttpObject();
	xmlHttp.open("GET","data_toggle.aspx?cmd="+e+a+"&rnd="+Math.random(),true);
	xmlHttp.send(null);
	return false;
}

// Shopping Bag
function removeitem(a) {
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedBag;
	xmlHttp.open("GET","data_shoppingbag.aspx?cmd=remove&id="+a+"&rnd="+Math.random(),true);
	xmlHttp.send(null);
}
function changevat(a) {
	if(document[a].vat.selectedIndex > 0) {
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=stateChangedBag;
		xmlHttp.open("GET","data_shoppingbag.aspx?cmd=vat&country="+document[a].vat[document[a].vat.selectedIndex].value+"&rnd="+Math.random(),true);
		xmlHttp.send(null);
		return false;
	}
}
function addtobag(a) {    
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedBag;
	b = document.form1.drpColors[document.form1.drpColors.selectedIndex].value;
	c = document.form1.drpSizes[document.form1.drpSizes.selectedIndex].value;
	d = document.form1.drpQuantity[document.form1.drpQuantity.selectedIndex].value;	
	xmlHttp.open("GET","data_shoppingbag.aspx?cmd=add&id="+a+"&color="+b+"&size="+c+"&qty="+d+"&rnd="+Math.random(),true);
	xmlHttp.send(null);
	document.getElementById("bagopen").style.display="none";
	document.getElementById("bagclose").style.display="block";
	document.getElementById("bag").style.display="block";
	self.scrollTo(0, 0);
}
function stateChangedBag() {
	if (xmlHttp.readyState==4) {
		document.getElementById("bag").innerHTML=xmlHttp.responseText;
		itemsinbag();
	}
}
function itemsinbag() {
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedItems;
	xmlHttp.open("GET","data_itemsinbag.aspx?rnd="+Math.random(),true);
	xmlHttp.send(null);
}
function stateChangedItems() {
	if (xmlHttp.readyState==4) {
		document.getElementById("ajaxitems").innerHTML=xmlHttp.responseText;
	}
}

// Change Item Attributes
function changeitem(a) {
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedItem;
	b = document.form1.drpColors[document.form1.drpColors.selectedIndex].value;
	c = document.form1.drpSizes[document.form1.drpSizes.selectedIndex].value;
	d = document.form1.drpQuantity[document.form1.drpQuantity.selectedIndex].value;	
    c = c.replace("+","plus");
	xmlHttp.open("GET", "data_addtobag.aspx?id=" + a + "&color=" + b + "&size=" + c + "&qty=" + d + "&rnd=" + Math.random(), true);
	xmlHttp.send(null);
}
function stateChangedItem() {
	if (xmlHttp.readyState==4) {
		document.getElementById("ajaxaddtobag").innerHTML=xmlHttp.responseText;
	}
}

// Product Browser
function activatebrowser(a) {
	xmlHttp=GetXmlHttpObject();
	if (flashver >= 8 && !window.opera && xmlHttp!=null) {
		if (a == "open") {
			document.getElementById("browserclose").style.display="block";
			document.getElementById("browseropen").style.display="none";
			document.getElementById("browser").style.display="block";
		} else {
			document.getElementById("browseropen").style.display="block";
		}
	}
}
function control(a) {
	setTimeout("thisMovie('objflashbrowser').control('"+a+"')",10);
	return false;
}

function checkEvent(ypos){
    alert("yPos" + ypos);
}

function activatebutton(a,b,c) {
	if (c == "hide") {
		d = "<span>"+b+"</span>";
	} else {
		d = "<a href=\"\" onclick=\"return control('"+a+"');\">"+b+"</a>";
	}
	document.getElementById(a).innerHTML = d;
}
function goitem(a) {
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedProd;
	xmlHttp.open("GET","data_product.aspx?id="+a+"&rnd="+Math.random(),true);
	xmlHttp.send(null);
	return false;
}
function stateChangedProd() {
	if (xmlHttp.readyState==4) {
		document.getElementById("ajaxproduct").innerHTML=xmlHttp.responseText;
		initExtAPI("objflashzoomer");
	}
}
function changefilter(a) {
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChangedFilter;
	b = document.form1.brand[document.form1.brand.selectedIndex].value;	
	/*c = document.form1.designer[document.form1.designer.selectedIndex].value;*/
    
	setTimeout("thisMovie('objflashbrowser').control('refresh','"+b+"')",10);
	xmlHttp.open("GET","data_browsefilter.aspx?brand="+b+"&category="+a+"&rnd="+Math.random(),true);
	xmlHttp.send(null);
}
function stateChangedFilter() {
	if (xmlHttp.readyState==4) {
		document.getElementById("ajaxbrowsefilter").innerHTML=xmlHttp.responseText;
	}
}

// Product Zoomer
function display(a,b,c) {
    if (flashver >= 8) {        
	    setTimeout("thisMovie('obj" + a + "').loadimg('" + b + "')", 100);
		
		if (c!=null) {
			useimage(c);
		}
		return false;
	} else {
		alert("Sorry, You need flash 8 or more to view this image.")
		return false;
	}
}
function thisMovie(movieName) {
    if (document.all || window.opera) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
function useimage(a) {
	document.form1.imgcode.value='<div style="line-height:0;"><img src="products/'+a+'.jpg" alt="" width="390" height="390"><br><span style="font-size:9px;font-family:arial;color:#999;line-height:18px;">Published with permission &amp; love from <a href="http://www.modashop.net" style="font-size:9px;font-family:arial;">www.modashop.net.</a> Copyright &copy; 2009</span></div>';
}

// ASP.NET form fix for Flash External API
function initExtAPI(a) {
	if (!window.opera) {
		window[a]=document.forms[0][a];
	}
}

function changeImage(a) {
    document.form1.ProdImg.src = 'http://server193.gestinweb.com/spinnakerNET/ObjImg/' + a;
}