﻿


var j;
   var ref;

var myWidth = 0, myHeight = 0;

function GetScreenSize() {
    myWidth = 1060;
    myHeight = 480;

 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;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
}

GetScreenSize();

setCookie('sw',myWidth,1);

    var cookieuserid
    cookieuserid=getCookie('i');
    
 var Skstring;
 var VisitorId;
    
	if (cookieuserid==null || cookieuserid=="")
  {

	setCookie('i',VisitorId,365);	

  	
		// change the links in the document for tracking and screen res.
 		for (var i=0; i<=(document.links.length-1); i++) 
 		{	    
			ref = document.links[i].href;
			if ((ref.indexOf('#') < 0) & (ref.indexOf('javascript') < 0)& (ref.indexOf('@') < 0) )
			{
				j = ref.indexOf('?');
				if ( document.links[i].target != '_blank' )
				{
					if (j > 0 )
					{
						if (Skstring != ''){
							document.links[i].href = document.links[i].href + '&sw='  + myWidth + "&i=" + VisitorId + "&sk=" +  Skstring;
						}else{
							document.links[i].href = document.links[i].href + '&sw='  + myWidth + "&i=" + VisitorId ;
						}
					}
					else
					{
						  //document.links[i].href = document.links[i].href + '?sw='  + myWidth + "&i=" + VisitorId;
						if (Skstring != ''){
							document.links[i].href = document.links[i].href + '?sw='  + myWidth + "&i=" + VisitorId + "&sk=" +  Skstring;
						}else{
							document.links[i].href = document.links[i].href + '?sw='  + myWidth + "&i=" + VisitorId ;
						}
			
					}
				}
			}			
	    }
   }else{
   
	   	if (Skstring != ''){
	 		for (var i=0; i<=(document.links.length-1); i++) 
	 		{
				ref = document.links[i].href;
				if ((ref.indexOf('#') < 0) & (ref.indexOf('javascript') < 0)& (ref.indexOf('@') < 0) )
				{
					j = ref.indexOf('?');
					if ( document.links[i].target != '_blank' )
					{
						if (j > 0 )
						{
							document.links[i].href = document.links[i].href + '&sk='  + Skstring;
						}else{
							document.links[i].href = document.links[i].href + '?sk='  + Skstring;
						}
					}
				}	 			    
	   		}	   		
	   	}
   
   }


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

