﻿// JScript File




function ValidateRequiredInteger(oSrc, args)
{
    args.IsValid = !isNaN(args.Value);
    
}

function ValidateRequired(oSrc, args)
{
    args.IsValid = (args.Value.trim().length >= 1);
}

function ValidateDecimal(oSrc, args)
{
    args.IsValid = !isNaN(args.Value.trim());
}


function ValidateEmail(oSrc, args)
{
    args.IsValid = echeck(args.Value);
}



function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }

 		 return true					
	}

function openHelp(helpCode)
{
    var allProperties = "height=700,width=1000,resizable=yes,scrollbars=yes,top=200,left= " + ((windowWidth() / 2) -410);
    var the_url = document.URL;
    var lead_slashes = the_url.indexOf("//") + 2;
    var without_resource = the_url.substring(lead_slashes, the_url.length);
    var next_slash = without_resource.indexOf("/");
    var domain = without_resource.substring(0, next_slash);    
    var helpUrl = "http://"+ domain +"/pages/help.aspx?helpcode="+ helpCode;
    window.open(helpUrl, 'Artica', allProperties)
}



function windowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function windowCenter()
{
 return windowWidth / 2;
}

function highlightOn(elm)
{
    elm.style.background='#FFCC66';
}

function highlightOff(elm)
{
    elm.style.background='transparent';
}

function OverlaySelected(img)
{
    img.src = "../Images/Product_Tn_Bgd2.gif";
}

function OverlayNormal(img)
{
 img.src = "../Images/Product_Tn_Bgd_m.gif";
}

function FrontImgOver(artistId,clientId,productIndeks)
{
    var lnk = document.getElementById(clientId+"_aid:"+artistId);
    lnk.style.background ="#1E9BC5";
    lnk.style.color = "#FFFFFF";
    
    if(productIndeks == null || productIndeks ==  undefined)
    {
        var i2= document.getElementsByName(clientId+":"+artistId);
        for(i = 0;i<i2.length;i++)
        {
            i2[i].src ="../Images/Product_Tn_Bgd2.gif";
        }
        
        setAllNameDivsDisplayStyle(clientId+"_aname:"+artistId,"block");
        
    }else
    {
    
        var img = document.getElementById(clientId+"_overlay:"+artistId+":"+productIndeks);
        img.src ="../Images/Product_Tn_Bgd2.gif";
    
        var nameDiv = document.getElementById(clientId+"_aname:"+artistId+":"+productIndeks);
        nameDiv.style.display ="block";
    }
    
    
    
}
function FrontImgOut(artistId,clientId,productIndeks)
{
    var lnk = document.getElementById(clientId+"_aid:"+artistId);
    lnk.style.background = "#FFFFFF";
    lnk.style.color = "#727272";
    
     if(productIndeks == null || productIndeks == undefined)
    {
         var i2= document.getElementsByName(clientId+":"+artistId);
        for(i = 0;i<i2.length;i++)
        {
        i2[i].src ="../Images/Product_Tn_Bgd_m.gif";
        }
        
        setAllNameDivsDisplayStyle(clientId+"_aname:"+artistId,"none");

    }else
    {
    var img = document.getElementById(clientId+"_overlay:"+artistId+":"+productIndeks);
    img.src ="../Images/Product_Tn_Bgd_m.gif";
    
    var nameDiv = document.getElementById(clientId+"_aname:"+artistId+":"+productIndeks);
    nameDiv.style.display ="none";
    }
}

function setAllNameDivsDisplayStyle(partialid,styleValue)
{

var re= new RegExp(partialid,'g');
//var contElm = document.getElementById(containerID);
var elems =  document.getElementsByTagName('*'), i=0, el;
    while(el=elems[i++])
    {
        if(el.id.match(re))
        {
         el.style.display = styleValue;
        }
    }   
}

function ExpandOrCollapse(ec)
{
    var imgWidth = $find("imgPnl3");
    if(imgWidth.style.width != "900px" )
    {
        
        if(ec == 1) return true; else return false;
    }else
        if(ec == 0) return true; else return false;
}




if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();




