//====================================
function SetStyleForBlackForm() {
    try
    {
    	$('blackForm').setStyle('width',this.GetPageSize()[0]+'px');
    	$$('.blackBox').setStyle('height',this.GetPageSize()[1]+'px');
    }catch(e){}
}
//====================================
function SetStyleForLightForm() {
    $$('.lightBox').setStyle('left',Math.abs(((this.GetPageSize()[2])-800)/2)+this.GetPageSize()[4]+'px');
    $$('.cv_lightBox').setStyle('left',Math.abs(((this.GetPageSize()[2])-500)/2)+this.GetPageSize()[4]+'px');
    //$$('.lightBox').setStyle('top', Math.abs(((this.GetPageSize()[3])-600)/2)+this.GetPageSize()[5]+'px');
}
//====================================
function GetPageSize(){
   	var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
    	xScroll = window.innerWidth + window.scrollMaxX;
    	yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	    xScroll = document.body.scrollWidth;
	    yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    	xScroll = document.body.offsetWidth;
    	yScroll = document.body.offsetHeight;
    }

   	var windowWidth, windowHeight;

    if (self.innerHeight) {	// all except Explorer
	    if(document.documentElement.clientWidth){
	    	windowWidth = document.documentElement.clientWidth;
	    } else {
		    windowWidth = self.innerWidth;
	    }
    	windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	    windowWidth = document.documentElement.clientWidth;
	    windowHeight = document.documentElement.clientHeight;
   	} else if (document.body) { // other Explorers
   		windowWidth = document.body.clientWidth;
   		windowHeight = document.body.clientHeight;
   	}

   	// for small pages with total height less then height of the viewport
   	if(yScroll < windowHeight){
   		pageHeight = windowHeight;
   	} else {
   		pageHeight = yScroll;
   	}

   	// for small pages with total width less then width of the viewport
   	if(xScroll < windowWidth){
   		pageWidth = xScroll;
   	} else {
   		pageWidth = windowWidth;
   	}

       //get scroll coordinates
       var xCoord;
       var yCoord;
       if (document.all){
               xCoord = document.documentElement.scrollLeft;
               yCoord = document.documentElement.scrollTop;
           }
       else{
               xCoord = window.pageXOffset;
               yCoord = window.pageYOffset;
           }

	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xCoord,yCoord)
	return arrayPageSize;
}
//======================================
function checkEmail(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 printdiv(aId) {
   var atext = ''
   if (aId!='lightbox_job')
   {    var title = $(aId).getFirst().getFirst().innerHTML;
    var location = $(aId).getFirst().getFirst().getNext().innerHTML;
    var salary_range = $(aId).getFirst().getFirst().getNext().getNext().innerHTML;
    var description = $(aId).getFirst().getFirst().getNext().getNext().getNext().getFirst().innerHTML;
    var ref = 'Ref: '+aId.substring(4, aId.length)*1;


    atext = '<div id="lightbox_job" class="lightbox_job">'+
    '<div class="lightbox_job_title">'+title+'</div>'+
    '<div class="lightbox_job_location">'+location+'</div>'+
    '<div class="lightbox_job_salary">'+salary_range+'</div>'+
    '<div class="lightbox_job_description">'+description+'</div>'+
    '<div class="lightbox_job_ref">'+ref+'</div>'+
    '</div>';
   }
   else
   {   	    atext = document.getElementById(aId).innerHTML;
   }



    var captext = window.document.title;
    var alink = window.document.location;
    var prwin = open('');
    prwin.document.open();
    prwin.document.writeln('<html><head><title>Version for print<\/title><\/head><body text="#000000" bgcolor="#FFFFFF"><div onselectstart="return false;" oncopy="return false;">');
    //prwin.document.writeln('<script type="text/javascript">function p_print(){window.print();}</script>');
    /*prwin.document.writeln('<script language="javascript">'+
                           'function prepare(b)'+
                           '{'+
                           '    if(b==true)'+
                           '    {'+
                           '	    document.getElementById("p_top_butt").style.display="none";'+
                           '	    document.getElementById("p_copy").style.display="none";'+
                           '	    document.getElementById("p_source").style.display="none";'+
                           '	    document.getElementById("p_bott_butt").style.display="none";'+
                           '	    window.print();'+
                           '    }'+
                           '    else'+
                           '    {'+
                           '	    document.getElementById("p_top_butt").style.display="";'+
                           '	    document.getElementById("p_copy").style.display="";'+
                           '	    document.getElementById("p_source").style.display="";'+
                           '	    document.getElementById("p_bott_butt").style.display="";'+
                           '    }'+
                           '}'+
                           '</script>');*/
    prwin.document.writeln('<div id="p_top_butt" style="margin-bottom:5px;"><a href="javascript:window.print();">Print<\/a> | <a href="javascript://" onclick="window.close();">Close window<\/a><\/div><hr>');
    //prwin.document.writeln('<h1>'+captext+'<\/h1>');
    prwin.document.writeln(atext);
    prwin.document.writeln('<hr><div id="p_copy" style="font-size:8pt;margin-top:20px;">&copy; ISE Partners<\/div>');
    prwin.document.writeln('<div id="p_source" style="font-size:8pt;">Source page: '+alink+'<\/div>');
    prwin.document.writeln('<div id="p_bott_butt" style="margin-top:5px;"><a href="javascript:window.print();">Print<\/a> | <a href="javascript://" onclick="window.close();">Close window<\/a><\/div>');
    prwin.document.writeln('<\/div><\/body><\/html>');
    prwin.document.close();

}

