﻿// JScript File
window.onload = OnPageLoad;
function OnPageLoad()
{
    DetectRes();
}
function DetectRes()
{
    var width = screen.width;
    var left = 'site_left';
    var left2 = 'site_left2';
    
    if (width >= 1024){}
    else if(width<1024 && width >=640){invisible(left);invisible(left2);}
    else if (width < 640) {location.ref='/index_m.aspx';}
    else {}
}
function ConfirmMessage(msg)
{
    return confirm(msg);
}
function refreshParent() 
{
    window.opener.location.href = window.opener.location.href;
    if (window.opener.progressWindow)window.opener.progressWindow.close()
    window.close();
}
function PopUpWindow(url,title,width,height,resizeable,displaybutton,Hmargin,Vmargin)
{
	resizeable = (resizeable!="") ? resizeable : "1";
	displaybutton = (displaybutton!="") ? displaybutton : "0";
	width = (width=="") ? "800" : width;
	height = (height=="") ? "600" : height;
	title = (title=="") ? "New Window" : title;
	Hmargin = (Hmargin=="") ? "50" : Hmargin;
	Vmargin = (Vmargin=="") ? "50"  : Vmargin;
	
	if(url!="")
	{
		window.open( url, title, 'location = ' + displaybutton + ',toolbar = 0, status = 1, scrollbars = 1, height = ' + height + ', width = ' + width + ', top = ' + Vmargin + ', left = ' + Hmargin + ' ,resizable = '+ resizeable + '' )
	}
}
function EmailToFriend()
{
    var URLToEmail = window.location.href;
    Set_Cookie('URLToEmail', URLToEmail, '600', '/', '', '');
    PopUpWindow('http://www.laborie.com/Common/EmailToFriend.aspx','newWin','540','360','1','1','50','50');
}
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
    var today = new Date();
    today.setTime(today.getTime());

    if(expires)
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));

    document.cookie = name + "=" +escape( value ) +
    ((expires) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ((path) ? ";path=" + path : "" ) + 
    ((domain) ? ";domain=" + domain : "" ) +
    ((secure) ? ";secure" : "" );
}
function Get_Cookie(name) 
{
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) &&
    ( name != document.cookie.substring( 0, name.length ) ) )
    {
    return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
function Delete_Cookie( name, path, domain ) 
{
    if ( Get_Cookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function isIE(){if (navigator.appVersion.indexOf("MSIE")!=-1){ return true } return false;}
function getSelectedValue(ele) {return gID(ele).options[gID(ele).selectedIndex].value ; }
function redirect(link) { if(link.length > 0) {window.location = link; } }
function gID(ele) { return document.getElementById(ele); }
function invisible(ele) { gID(ele).style.display = 'none'; }
function visible(ele) {gID(ele).style.display='block'; }

//string function
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function gup( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}