﻿function goAction(sAction)
{
	//-- Post Form to a specific page according to sAction
	if(sAction == null)
	    return; 
	var f = document.aspnetForm; 

	switch(sAction)
	{
	    case 'Email':
	        f.action = '<%=Icom.Global.IcomCommon.GetURL("/email.aspx", this.mscssid, false) %>'; 
		    break; 
	    default :
		    f.action = '<%=Icom.Global.IcomCommon.GetURL("/index.aspx", this.mscssid, false)%>'; 
	}
	//-- Post form
	f.submit(); 
}


function highlight(elt,state) 
{
var plus='';
if (navigator.appName=='Netscape' || navigator.appVersion.indexOf('MSIE 7.0')>=0) plus='_Firefox';
if (elt.tagName=='INPUT') 
{
		etype=elt.type;
		if ((etype=='text' || etype=='password'))
		{
			if(state==1)
                elt.className="out"+plus; 
			else 
			    elt.className="on"+plus;
		}
	}
}


function IE_CorrectAlpha_PNG()
{
	for(i=0; i<document.images.length; i++)
	{
		img    = document.images[i];
		imgExt  = img.src.substring(img.src.length-3, img.src.length);
		imgExt  = imgExt.toUpperCase();
		if (imgExt == "PNG")
		{
			imgID    = (img.id) ? "id='" + img.id + "' " : "";
			imgClass= (img.className) ? "class='" + img.className + "' " : "";
			imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			imgStyle= "display:inline-block;" + img.style.cssText;
			if (img.align == "left") { imgStyle = "float:left;"  + imgStyle; } else if (img.align == "right"){ imgStyle = "float:right;" + imgStyle; }
			if (img.parentElement.href)   { imgStyle = "cursor:hand;" + imgStyle; }
			strNewHTML    = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');"></span>';
			img.outerHTML = strNewHTML;
			i = i-1;
		}
	}
}
var userAgent=navigator.userAgent;
if (userAgent.indexOf('MSIE') != -1) {
	window.attachEvent("onload", IE_CorrectAlpha_PNG);
}



//Show waiting message
function displayWait(display)
{
	document.getElementById('_wait').style.display = display?display:'';
}
    
    
    //Stop waiting message
function StopdisplayWait()
{
	document.getElementById('_wait').style.display = 'none';
}

function getKeyCode(e){
	var chrCode
	if(e && e.which){ 
		e = e
		chrCode = e.which 
	}else{
		e = event
		chrCode = e.keyCode 
	}
	return chrCode
}

function checkInvalidCharacters(e,invalidChars){
    invalidChars = invalidChars.replace(/&quot;/ig,'"')
	var chrCode	= getKeyCode(e)
	var character = String.fromCharCode(chrCode)
	var reg = new RegExp("[" + invalidChars + "]")
	if(character.match(reg))
		return false
	else
		return true
}

function checkValidCharacters(e,validChars){
    validChars = validChars.replace(/&quot;/ig,'"')
	var chrCode	= getKeyCode(e)
	if(chrCode == 8)
	    return true
	var character = String.fromCharCode(chrCode)
	var reg = new RegExp("[" + validChars + "]")
	if(character.match(reg))
		return true
	else
		return false
}

function trim(s){
	s = s.replace(/^\s*|\s*$/,"");
	return s;
}

var popbox = null
function checkPop(){
	if(popbox && popbox.close) popbox.close()
}

function goAlert(idProduct,lbManufacturer,lbRange){
	window.open('<%=IcomCommon.GetURL("/catalogue/catProductAlert.aspx","displayHeader","no","isPopup","y")%>&idProduct=' + idProduct + '&lbManufacturer=' + lbManufacturer + '&lbRange=' + lbRange + '', '', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,width=500,height=300,left=100,top=100')
}

function goContactInfo(idProduct,lbManufacturer,lbRange){
	checkPop()
	var iWidth=500, iHeight=350
	if(idProduct == null || idProduct == '' || idProduct == 0)
		return
	else
	    return
		//popbox = window.open('<%=IcomCommon.GetURL("/catalogue/catProductCorporateLocalInfoAlert.aspx","displayHeader","no","isPopup","y")%>' + '&idProduct=' + idProduct + '&lbManufacturer=' + lbManufacturer + '&lbRange=' + lbRange, '', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,resizable=no,width=' + iWidth + ',height=' + iHeight + ',left=' + Math.round((window.screen.width - iWidth) / 2) + ',top=' + Math.round((window.screen.height - iHeight) / 2))
}

function goSupplierInfo(idSupplier){
	checkPop()
	var iWidth=500, iHeight=220
	if(idSupplier == null || idSupplier == '' || idSupplier == 0)
		return
	else
	    return
		//popbox = window.open('<%=IcomCommon.GetURL("/catalogue/catProductSupplierInfoAlert.aspx","isPopup","yes","displayHeader","no")%>' + '&idSupplier=' + idSupplier, '', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,resizable=no,width=' + iWidth + ',height=' + iHeight + ',left=' + Math.round((window.screen.width - iWidth) / 2) + ',top=' + Math.round((window.screen.height - iHeight) / 2))
}