<!--
/********** menu new design **************************/
var overImg_Design = null;
var normImg_Design = null;

roll = false;

function preloadMenu_Design(count) {
	overImg_Design = new preloadImages_Design(count,'/data/NewDesign/m_','_on.png');
	normImg_Design = new preloadImages_Design(count,'/data/NewDesign/m_','.png');
	roll = true;
}

function preloadImages_Design(length, path, type) {
    for(var i = 1; i <= length; i++) {
	this[i]= new Image();
	this[i].src= path + i + type;
    }
    return this;
}

function rollOn_Design(num) {
    if(roll && document.images) { 
	eval('document.images["m_'+num+'"].src='+'overImg_Design[num].src')
    }
}

function rollOff_Design(num) {
    if(roll && document.images){
	eval('document.images["m_'+num+'"].src='+'normImg_Design[num].src')
    }
}
/********** menu new design **************************/
/*********************polls view********************/
function showPoll(url) {
    var width = 510,
        height = 400;

    hwnd = window.open(url, "Results", "left=" + ((screen.availWidth  - width) / 2) + ",top=" + ((screen.availHeight  - height) / 2) + ",width=" + width + ",height=" + height + ",titlebar=1,resizable=1, scrollbars=1");
    hwnd.focus();

}
/*********************polls view*****************/
/*******************check forms message**************/
function Wrong(el, mes) {
	alert(mes);
	el.focus();
	return false;
}
/******************check forms message**********************/






var overImg = null;
var normImg = null;

var loadDone = false;

////////////////////////////////////////////////////////////////////////

/* function for body.onLoad */

function initPage2() {
	preloadMenu(9);
	loadDone = true;
}
////////////////////////////////////////////////////////////////////////

function setObjHeight(objone, objtwo, objthree, objfour){
	var objthreeHeight = objthree.clientHeight;	
	var objfourHeight = objfour.clientHeight;
	var sobjthreeVar = String(objthreeHeight - 58);
	var sobjfourVar = String(objfourHeight - 58);
	var variance = parseInt(objthreeHeight) - parseInt(objfourHeight);
	if (variance < 0) {
		objone.style.height = sobjfourVar + "px";
	} else if (variance > 0) {
		objtwo.style.height = sobjthreeVar + "px";
	} else {
		objone.style.height = sobjfourVar + "px";
		objtwo.style.height = sobjthreeVar + "px";
	}
}

/*Directory Listing*/
function addop(){
	var listObj = document.getElementById("txtPCList");
	var ListObjTwo = document.getElementById("txtPCSelect");
	
	if(listObj.type){
		for(var i = 0; i < listObj.length; i++) {
			if(listObj.options[i].selected){
				if(repetitionop(listObj.options[i].text)){
					ListObjTwo.options[ListObjTwo.length] = new Option(listObj.options[i].text, listObj.options[i].value);
				}	
			}
		}
	}
}

function removeop(){
	var ListObjTwo = document.getElementById("txtPCSelect");
                     var lengthListObjTwo = ListObjTwo.length;
	
	if(ListObjTwo.type){
		for(var i = 0; i < ListObjTwo.length; i++) {
			if(ListObjTwo.options[i].selected){
				ListObjTwo.remove(i);
                i--;
			}
		}
	}
}

function repetitionop(objone){
	var ListObjTwo = document.getElementById("txtPCSelect");
	
	if(ListObjTwo.type){
		for(var i = 0; i < ListObjTwo.length; i++) {			
			if(String(ListObjTwo.options[i].text) == String(objone)){		
				return false;
			}			
		}
	}
	return true;
}

function selectedop(){
	var ListObjTwo = document.getElementById("txtPCSelect");
                     var sStr = "";	

	if(ListObjTwo.type){
		for(var i = 0; i < ListObjTwo.length; i++) {	
                                                                if(i == 0){sStr = ListObjTwo[i].value; } else {sStr += ", " + ListObjTwo[i].value; }
		}
                      document.f.elemsl.value = sStr;
	}	
}

function sameInf(){
                      var Sci = document.getElementById("sci");
  
                      if(Sci.checked == true){
                               document.f.txtCompany.value = document.f.txtYourName.value;
                               document.f.txtEmailAddress_c.value = document.f.txtEmailAddress.value;
                               document.f.txtPhone_c.value = document.f.txtPhone.value;
                               document.f.txtFaxNumber_c.value = document.f.txtFaxNumber.value;
                               document.f.txtStreetAddress_c.value = document.f.txtStreetAddress.value;
                               document.f.txtCity_c.value = document.f.txtCity.value;
                               document.f.txtZipCode_c.value = document.f.txtZipCode.value;
                               document.f.txtState_c.value = document.f.txtState.value;

                               document.f.txtCompany.disabled = true;
                               document.f.txtEmailAddress_c.disabled = true;
                               document.f.txtPhone_c.disabled = true;
                               document.f.txtFaxNumber_c.disabled = true;
                               document.f.txtStreetAddress_c.disabled = true;
                               document.f.txtCity_c.disabled = true;
                               document.f.txtZipCode_c.disabled = true;
                               document.f.txtState_c.disabled = true;
                      } else {
                               document.f.txtCompany.value = "";
                               document.f.txtEmailAddress_c.value = "";
                               document.f.txtPhone_c.value = "";
                               document.f.txtFaxNumber_c.value = "";
                               document.f.txtStreetAddress_c.value = "";
                               document.f.txtCity_c.value = "";
                               document.f.txtZipCode_c.value = "";
                               document.f.txtState_c.value = "Select State";

                               document.f.txtCompany.disabled = false;
                               document.f.txtEmailAddress_c.disabled = false;
                               document.f.txtPhone_c.disabled = false;
                               document.f.txtFaxNumber_c.disabled = false;
                               document.f.txtStreetAddress_c.disabled = false;
                               document.f.txtCity_c.disabled = false;
                               document.f.txtZipCode_c.disabled = false;
                               document.f.txtState_c.disabled = false;
                      }

                      return true;
}

function sameInfTwo(){
                      var Sci = document.getElementById("sci");

                      if(Sci.checked == true){                               
                               document.f.txtCompany.disabled = true;
                               document.f.txtEmailAddress_c.disabled = true;
                               document.f.txtPhone_c.disabled = true;
                               document.f.txtFaxNumber_c.disabled = true;
                               document.f.txtStreetAddress_c.disabled = true;
                               document.f.txtCity_c.disabled = true;
                               document.f.txtZipCode_c.disabled = true;
                               document.f.txtState_c.disabled = true;
                      } 
}

function ChangesConInf(str){

                      var Sci = document.getElementById("sci");

                      if(Sci.checked == true){  
                                   switch (str) {
                                             case "name" : document.f.txtCompany.value = document.f.txtYourName.value; break;
                                             case "email" : document.f.txtEmailAddress_c.value = document.f.txtEmailAddress.value; break;
                                             case "phone" : document.f.txtPhone_c.value = document.f.txtPhone.value; break;
                                             case "fax" : document.f.txtFaxNumber_c.value = document.f.txtFaxNumber.value; break;
                                             case "address" : document.f.txtStreetAddress_c.value = document.f.txtStreetAddress.value; break;
                                             case "city" : document.f.txtCity_c.value = document.f.txtCity.value; break;
                                             case "zip" : document.f.txtZipCode_c.value = document.f.txtZipCode.value; break;
                                             case "state" : document.f.txtState_c.value = document.f.txtState.value; break;
                                   }                             
                                   
                      } 

}
/*end Directory Listing*/

/*buyersguide*/
function setDivHeight(){
      var tableHeight = document.getElementById("tabcon").clientHeight;      
      var banerdivH = document.getElementById("banners-main").clientHeight;
      var intTableHeight = parseInt(tableHeight) - 15;      
      var intBanerdivH = parseInt(banerdivH) - 35;      
             if(intTableHeight < intBanerdivH) { intTableHeight = intBanerdivH; }
             tableHeight = String(intTableHeight);
             document.getElementById("divcon").style.height = tableHeight+"px";     
}

function clearSearchText(obj){
          if(obj.value == "Search"){
                    obj.value = "";
          }
}
/*end buyersguide*/

/* functions for menu and other images */
function preloadMenu(count) {
	overImg = new preloadImages(count,'/data/images/menu/menu-','-on.gif')
	normImg = new preloadImages(count,'/data/images/menu/menu-','-off.gif')
}

function preloadImages(length, path, type) {
    for(var i = 1; i <= length; i++) {
	this[i]= new Image();
	this[i].src= path + i + type;
    }
    return this;
}

function rollOn(num) {
    if(loadDone && document.images) { 
	eval('document.images["m-'+num+'"].src='+'overImg[num].src')
    }
}

function rollOff(num) {
    if(loadDone && document.images){
	eval('document.images["m-'+num+'"].src='+'normImg[num].src')
    }
}




function sizeImg(obj, _width) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
    if (tmpImg.width > _width) { obj.width = _width; }
}

function sizeImgWH(obj, _w, _h) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
    if (tmpImg.height > _h) { obj.height = _h; }
    if (tmpImg.width > _w) { obj.width = _w; }
}

function sizeImgWHpropor(obj, _w, _h) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
	var differenceH = 0;
	var differenceW = 0;
    if (tmpImg.height > _h) { 
		differenceH = obj.height - _h;
	}
    if (tmpImg.width > _w) { 
		differenceW = tmpImg.width - _w;
	}
	if (differenceH >= differenceW && differenceH != 0){
		obj.width = Math.round(_h * obj.width / obj.height);
		obj.height = _h;
	} else if (differenceW != 0){
		obj.height = Math.round(_w * obj.height / obj.width);
		obj.width = _w;
	}
}
function SIP(obj, _w, _h) {
  /////////////// this is the correct function is proportional to change size
  var tmpImg = new Image();
  tmpImg.src = obj.src;
  //alert(tmpImg.width)
  if (_w/tmpImg.width > _h/tmpImg.height) {
  	if (tmpImg.width > _w) {
      obj.height = tmpImg.height*(_w/tmpImg.width);
      obj.width = _w;
    }
    if (tmpImg.height > _h) {
		  obj.width = tmpImg.width*(_h/tmpImg.height);
		  obj.height = _h;
    }
	} else {
    if (tmpImg.height > _h) {
		  obj.width = tmpImg.width*(_h/tmpImg.height);
		  obj.height = _h;
    }
  	if (tmpImg.width > _w) {
      obj.height = tmpImg.height*(_w/tmpImg.width);
      obj.width = _w;
    }
  }
}

////////////////////////////////////////////////////////////////////////

/* function to open print\email window */
function PrinterFriendlyNoPopup(url){
	remote = window.open("http://" + getDomainName() + url, "_self");

    	if (remote.opener == null) remote.opener = window;
}
function PrinterFriendly(url) {
    var width = 700,
        height = 550;
	if(String(url).indexOf('test') > 0){	
		PrinterFriendlyNoPopup(url);
	}else{
    	remote = window.open("http://" + getDomainName() + url, "opener", "scrollbars=1,resizable=1,toolbar=1,left=" + ((screen.availWidth  - width) / 2) + ",top=" + ((screen.availHeight  - height) / 2) + ",width=" + width + ",height=" + height);

    	if (remote.opener == null) remote.opener = window;
	}
}


function PrinterFriendly760(url) {
    var width = 760,
        height = 430;
    remote = window.open( /*** "http://" + getDomainName() +  ***/ url, "opener", "menubar=0,scrollbars=0,resizable=0,toolbar=0,left=" + ((screen.availWidth  - width) / 2) + ",top=" + ((screen.availHeight  - height) / 2) + ",Width=" + width + ",height=" + height);
    if (remote.opener == null) remote.opener = window;
}


function getDomainName() {
	var url = window.location.href;
	var end = url.indexOf("/", 7);
	if (end == -1) { end = url.length; }
	return url.substring(7, end);
}

/* function that show tip on your status bar when you take mouse over print\email link */
function showText(obj) {
    obj.onmouseout = function() { window.status = ""; }
    window.status = obj.innerText;
}

////////////////////////////////////////////////////////////////////////

/* functions that check different forms for correct information */

function checkRegForm(formobj) {
    with(formobj) {
	if (email.value.length == 0) { alert("Please, enter your email."); email.focus(); return false; }
	if (!checkEmail(email.value)) { alert("Please, enter valid email address."); email.focus(); return false; }
	if (cemail.value.length == 0) { alert("Please, confirm your email."); cemail.focus(); return false; }
	if (email.value != cemail.value) { alert("Email confirmation failed."); cemail.focus(); return false; }
    }

    return true;
}



function checkEmail(email) {
    var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return myRegExp.test(email);
}
function checkMail(mail) {
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return myRegExp.test(mail);
}

function getCookie(name) {

	var regExp 	= new RegExp(name + "=([^;]*)","gi");
	var ck 		= regExp.exec(String(document.cookie));	
	ck 			= RegExp.$1;

	return ck;
}


function httpRequestCreate() {
	
	// ==================================
	// Check browser capability.
	// ==================================
	var httpRequest = false;

	if ( window.XMLHttpRequest ) 
	{ // Mozilla, Safari
		httpRequest = new XMLHttpRequest();
	
		if ( httpRequest.overrideMimeType ) {
			// ==================================
			// For FF (generats an error in javascript console)
			// ==================================
	
			httpRequest.overrideMimeType('text/xml');
		}
	} else if ( window.ActiveXObject ) 
	{ // IE
		try {
			httpRequest = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) { /*document.write(e);*/ }
		}
	}

	return httpRequest;
	
}


function httpRequest(url, encoding, toReceive) {
	
	return httpRequestPost(url, encoding, toReceive,"");
	
	
	/*var toResolve		= 10000;
	var toConnect		= 10000;
	var toSend			= 40000;

	var request;
	var WinHttpReq;

	var request = "";
	try {
		var xmlHttpReq = httpRequestCreate(); //new ActiveXObject("MSXML2.XMLHTTP.3.0");
		xmlHttpReq.open("GET", url, false);
		xmlHttpReq.send();
		return xmlHttpReq.responseText;
		
		if(WinHttpReq.StatusText == "OK") {
			request = BinaryToString1(WinHttpReq.ResponseBody, encoding);
		} else { request = "1- " + WinHttpReq.StatusText; }
	} catch(e) { request = "2- " + "WinHttpRequest has caused an error"; }
	return request;*/
}

function httpRequestPost(url, encoding, toReceive, params) {
	var toResolve		= 10000;
	var toConnect		= 10000;
	var toSend			= 40000;

	var request;
	var WinHttpReq;
	
	var request = "";
	try {
		var xmlHttpReq = httpRequestCreate(); //new ActiveXObject("MSXML2.XMLHTTP.3.0");
		xmlHttpReq.open("POST", url, false);
		xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttpReq.setRequestHeader('HTTP_COOKIE', document.cookie);
		xmlHttpReq.send(params);
		return xmlHttpReq.responseText;

		
		if(WinHttpReq.StatusText == "OK") {
			request = BinaryToString1(WinHttpReq.ResponseBody, encoding);
		} else { request = "<div style=\"display: none;\">2-1 " + WinHttpReq.StatusText+"</div>"; }
	} catch(e) { request = "<div style=\"display: none;\">2-2 " + "WinHttpRequest has caused an error </div>"; }
	return request;
}

function _httpRequest(url,par)
{
 var httpR = false;
 if(window.XMLHttpRequest && !(window.ActiveXObject)) 
 {
  try { httpR = new XMLHttpRequest(); } catch(e) { httpR = false; }
 } else if(window.ActiveXObject) 
 {
  try { httpR = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { 
   try { httpR = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { httpR = false; }
  }
 }
 if (httpR) {
  httpR.open("POST", String(url), false);
  httpR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  httpR.send(par);
  return String(httpR.responseText);
 } else { return; }
} 

function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
                window.onload = func;
        }
        else {
                window.onload = function() {
                        oldonload();
                        func();
                }
        }
}

function addEvent(el, eType, fn, uC) {
	if (el.addEventListener) {
		el.addEventListener(eType, fn, uC);
		return true;
	} else if (el.attachEvent) {
		return el.attachEvent('on' + eType, fn);
	} else {
		el['on' + eType] = fn;
	}
} 

function saveView(r, url ){
	
	var valid = !isNaN(parseInt(r)) && url > "" && ( window.top === window.self ) ; 

	if ( valid ){
		var p = new Image(); 
		p.src = url + "avc.asp?r=" + parseInt(r) ; 		
	}
}
//-->
