<!-- Hide script from old browsers
// Make sure file is not hosted in a different frameset
if ( top.location.href != window.location.href )
  { top.location.href=window.location.href }

    function openWindow(url, w, h) {
        var windowprops = "width=" + w + ",height=" + h +",,left=10,top=10,scrollbars=yes,status=no,toolbar=no,location=no,directories=no,resizable=yes";
          popup = window.open(url,'newWin',windowprops);
          popup.focus();
           } 
        
	function openPicture(pic,w,h) {
     
		var windowprops = "left=160,top=100,scrollbars=no,status=yes,toolbar=no,location=no,directories=no,resizable=yes,width=" + w + ",height=" + h;
          
		picture = window.open('','newPicture',windowprops);
		picture.close();
        picture = window.open('','newPicture',windowprops);  
        picture.focus();
        
		picture.document.write("<html><head><title>Picture<\/title><\/head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>")
		picture.document.writeln("<img src=" + pic + " width=" + w + " height=" + h + ">")
		picture.document.write("<\/body><\/html>")
	}                
 
function showdate()
{
	
		// Determine the current date and display it
   	var today = new Date();
   	var day = today.getDay();
   	var date = today.getDate();
   	var month = today.getMonth();
   	var year = today.getFullYear();
   	
   		//January,February,March,April,May,June,July,August,September,October,November,December
   	if (month == 0) {month='Jan'};
   	if (month == 1) {month='Feb'};
   	if (month == 2) {month='Mar'};
   	if (month == 3) {month='Apr'};
   	if (month == 4) {month='May'};
   	if (month == 5) {month='Jun'};
   	if (month == 6) {month='Jul'};
   	if (month == 7) {month='Aug'};
   	if (month == 8) {month='Sept'};
   	if (month == 9) {month='Oct'};
   	if (month == 10) {month='Nov'};
   	if (month == 11) {month='Dec'};
   
   	if (day == 0) {day='Sunday'};
   	if (day == 1) {day='Monday'};
   	if (day == 2) {day='Tuesday'};
   	if (day == 3) {day='Wednesday'};
   	if (day == 4) {day='Thursday'};
   	if (day == 5) {day='Friday'};
   	if (day == 6) {day='Saturday'};
   
   if ( document.all ) {
		document.write ('<span class="small">&nbsp;&nbsp;' + day + ', ' + month +  ' ' + date + ', ' + year + '</span>');
	} else {
		document.write ('<span class="smallNC">&nbsp;&nbsp;' + day + ', ' + month +  ' ' + date + ', ' + year +  '</span>');
	}
   
   
}

function switchClass(obj,strClassName) {
		obj.className	= strClassName;
	}
	
function gotoURL(strUrl) {
		location = strUrl;
	}

function copyrightYear(startYear)
{
	d = new Date();
	
	if (startYear != d.getFullYear())
		{
		return startYear + " - " + d.getFullYear();
		}
	else
		{
		return startYear;
		}
}
	
	// Show current date in format "Nov 15, 2003".		
function nsDate()
{
		// Get today's date.
	var sDate = new Date();
	var sToday = "";
	
		// Array with months.
	var aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
		// Get current month.
	var iMonth = sDate.getMonth();
		
		// Get current hour,minute,second.
	var iHours   = sDate.getHours();
	var iMinutes = sDate.getMinutes();
	var iSeconds = sDate.getSeconds();
			
	sToday = "";
		// Get today's date string.
	sToday += aMonths[iMonth] + " ";
	sToday += sDate.getDate() + ", ";
	sToday += sDate.getFullYear() + " ";

		// Display the date on the screen.
	document.write("<b>"+sToday+"</b>");	
}

	// Get the current date in format "Nov 15, 2003  12:53:23 pm".
function today()
{
	var ie4=document.all;
    var ns4=document.layers;
    var ns6=document.getElementById&&!document.all;
    	
		// Get today's date.
	var sDate = new Date();
	var sToday = "";
	
		// Array with months.
	var aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
		// Get current month.
	var iMonth = sDate.getMonth();
		
		// Get current hour,minute,second.
	var iHours   = sDate.getHours();
	var iMinutes = sDate.getMinutes();
	var iSeconds = sDate.getSeconds();
	
		// If iHour > 12.
	if(iHours>12)
		iHours = iHours - 12;
	
	if(iMinutes < 10)
		iMinutes = "0" + iMinutes;
		
	if(iSeconds < 10)
		iSeconds = "0" + iSeconds;
	
	sToday = "";
		// Get today's date string.
	sToday += aMonths[iMonth] + " ";
	sToday += sDate.getDate() + ", ";
	sToday += sDate.getFullYear() + " ";
	
	sToday += iHours + ":";
	sToday += iMinutes + ":" ;
	sToday += iSeconds; 

	
		// Set am or pm
	if(sDate.getHours() < 12)
		sToday += " am ";
	else
		sToday += " pm ";
	
		// Display the date on the screen.
	
		// Write the clock to the layer:
	if (ns4) 
	{
		return;
	} 
	else 
		if (ie4) 
		{
			document.getElementById("LiveClock").innerHTML = "<b>"+sToday+"</b>";
		}	 
		else 
			if (ns6)
			{
				document.getElementById("LiveClock").innerHTML = "<b>"+sToday+"</b>";
            }            
	
		setTimeout("today()",1000);
		//window.setInterval(today(),100);
}	


function openWindow2(url,wname,w,h,props) 
{
	var winTop=(screen.height-h)/2;
	var winLeft=(screen.width-w)/2;
	
	var windowprops = "width=" + w + ",height=" + h +",left="+winLeft+",top="+winTop+","+props;
	return window.open(url,wname,windowprops);
}

/**
* check email 
*
*/
function validateEmail(email)
{
	if ((email.length < 3) || (email.length > 50) || 
			(email.charAt(0) == '@') || (email.charAt(email.length-1) == '@') || 
			(email.charAt(0) == '.') || (email.charAt(email.length-1) == '.') || 
			(email.indexOf('.') == -1) || (email.indexOf('@') == -1) ||
			(email.indexOf('@') != email.lastIndexOf('@')) || 
			(email.indexOf(' ') > 0) || (email.indexOf('?') > 0) || (email.indexOf('..') > 0)
			)
	{
		return false;
	}
	else
	{
		return true;
	}
} 

/**
* show/hide div tag if checkbox is checked
*
* @param string divID - id of div tag in html document
* @param string checkElem - checkbox element
*/
function ShowHide2(divID, checkElem)
{	
	var divTag = document.getElementById(divID);
	if (checkElem.checked) {
		divTag.style.display = 'block';
	} else {
		divTag.style.display = 'none';
	}
}

/**
* uncheck "all" checkbox for "Name" checkbox group if any ot other checkboxes is unchecked
*
* @param obj Item - item obeject that was clicked
* @param obj formElem - form in which this happens
* @param string Name - name of the checkboxes group
*/
function uncheckAll(Item, formElem ,Name)
{
	if(Item.checked == false)
	{
		// item from list is unchecked
		var len = formElem.elements.length;
		
		for (var i=0;i<len;i++)
		if (formElem.elements[i].name == Name)
		{ 
			// if this is "All" chekcbox with value = 0
 			if (formElem.elements[i].value == '0')
			{
				// uncheck it
				formElem.elements[i].checked = false;
			}						
		}
	}
}

/**
* check all checkbox for "Name" checkbox group if "All" checkbox is checked
*
* @param obj formElem - form in which this happens
* @param obj Item - checkbox checked
*/
function checkAll(formElem ,Item)
{
	var BoxesName = Item.name;
	
	if(Item.checked == true)
	{
		// item "All" from list is checked
		var len = formElem.elements.length;
		
		for (var i=0;i<len;i++)
		if (formElem.elements[i].name == BoxesName)
		{ 
			// check all boxes
			formElem.elements[i].checked = true;
		}
	}
}

function ShowHide(elemID) {
	var elem = document.getElementById(elemID);
	if (elem) {
		if (elem.style.display == 'none') {
			elem.style.display = 'block';
		} else {
			elem.style.display = 'none';
		}
	} else {
		alert(''+elemID+'');
	}
}

function ShowHideSub(industryID, changeImg) {
	var indID = industryID;
	var aDivs;
	
	if (changeImg) {
		
		var IndImg = document.getElementById('IndImg' + industryID);
		if (IndImg) {
			if (IndImg.src.indexOf("plus.jpg") > 0) {
				IndImg.src = '../images/minus.jpg';
			} else {
				IndImg.src = '../images/plus.jpg';
			}
		}
	}
	
	aDivs = document.getElementById(industryID).getElementsByTagName("div");		
	/*
	if (document.all) {
		// IE
		aDivs = getElementsByName_iefix("div", "Industry" + indID);
	} else {
		// other
		aDivs = document.getElementsByName('Industry' + indID);
	}
	*/
	for (var i =0; i < aDivs.length; i++ ) {
		if (aDivs[i].attributes['parent'].value == indID) {
			ShowHide(aDivs[i].id);
			
			// recurrence for lower levels
			if (aDivs[i].attributes['level'].value != 4) {					
				//ShowHideSub(aDivs[i].id, false);
			}
		}
	}				
}

/**
* show/hide Opportunitues div element
*
* @param DOM elements selectElem - account type selector
*/
function ShowHideOpportunituesCheckbox(selectElem) {
	var divElem = document.getElementById('OnlyPremAndVip');
	if (divElem) {
		if (selectElem.value != 1 && selectElem.value != '') {
			divElem.style.display = 'block';
		} else {
			divElem.style.display = 'none';
		}
	}
}

function UpdateNumberValue(countryID, elementID) {
	var phoneCode = '';
	if (countryID == 33) {
		phoneCode = '359';
	} else if (countryID == 177) {
		phoneCode = '40';
	} else {
		phoneCode = '';
	}
	/*
	var domElement;
	for (i = 0; i < elementIDs.length; i ++) {
		domElement = document.getElementById(elementIDs[i]);
	}
	*/
	domElement = document.getElementById(elementID);
	domElement.value = phoneCode;
}

function CalculateChars(textAreaObj, maxChars, remCharsSpan) {
	if (textAreaObj.value.length > maxChars) {
		// cut string
		textAreaObj.value = textAreaObj.value.substring(0,maxChars);
	} 
	var spanElem = document.getElementById(remCharsSpan);
	spanElem.innerHTML = textAreaObj.value.length + ' / ' + maxChars;
}

function HideAll(elementName) {
	var aElements = document.getElementsByName(elementName);
	
	for (i = 0; i < aElements.length; i ++) {
		var currElement = aElements[i];
		currElement.style.display = 'none';
	}
}

function CalculateCheckedIndustries(maxAllowedIndustries, checkboxElem) {
	
	if (checkboxElem.checked) {
		currentlyCheckedIndutries = currentlyCheckedIndutries + 1;
		if (currentlyCheckedIndutries > maxAllowedIndustries) {
			currentlyCheckedIndutries= currentlyCheckedIndutries - 1;
			alert('Maximum number of industries that you can select is ' + maxAllowedIndustries + '. You already checked maximum allowed industries.');
			return false;
		}		
	} else {
		currentlyCheckedIndutries= currentlyCheckedIndutries - 1;
		return true;
	}
	
	
	
	return true;
}

function GetUserPriority(companyEmail, prioritySelectId) {
	new Ajax.Request("../admin/return-user-account.php",
		{ 	method: 'get',
			parameters: {email: companyEmail},
			onSuccess: function(transport) {
					if (transport.responseText >= 1 && transport.responseText <= 3) {
						
						var selectElem = document.getElementById(prioritySelectId);
						if (selectElem) {											
							for (i = 0; i < selectElem.options.length; i ++) {
								if (selectElem.options[i].value == transport.responseText) {
									// select returned account type id
									selectElem.selectedIndex = i;
								}
							}
						}
					} else {
						alert(transport.responseText);
					}
				} 
		});	
}

function LoadingAnimation(elemID) {
	var elemObj = document.getElementById(elemID);
	elemObj.innerHTML = '<img src="../images/loading_new.gif" border="0" alt="" /><br />Loading ...';
}

function loadLogoutdata() {
	var elemObj1 = document.getElementById('UserTopMenuStatus');
	elemObj1.innerHTML = '<a href="register.php" class="topMenuLink" title="Sign In">Sign In</a>';
	
	new Ajax.Request("../en/ajax-segments.php",
		{ 	method: 'get',
			parameters: {cmd: 'loginform'},
			onSuccess: function(transport) {
					var elemObj2 = document.getElementById('LoginFormDiv');
					if (elemObj2) {
						elemObj2.innerHTML = transport.responseText;	
					}
				} 
		});	
	
	// redirect page to home page after 1 seconds
	var t = setTimeout ("document.location = 'index.php'", 1000);	
}

/**
* show/hide div element
*
* @param string divID - div element id
*/
function ShowHideDiv(divID, parentTop, parentLeft, offTop, offLeft, changeState) {
	divElem = document.getElementById(divID);
	if (divElem) {
		//alert(osTop);
		//alert(parentTop + ' ' + offTop + ' ' + parentLeft + ' ' + offLeft);
		iTop = parentTop + offTop;
		iLeft = parentLeft + offLeft;
		divElem.style.top = iTop + "px";
		divElem.style.left = iLeft + "px";
		//alert(divElem.style.left);
		if (divElem.style.display == 'block') {
			divElem.style.display = 'none';
		} else {
			divElem.style.display = 'block';
		}
		if (changeState) {
			new Ajax.Request( '../en/ajax-segments.php', { method: 'get' , parameters: {cmd: 'changeloginbehavior'} } );
		}
	}
}

// **************************************************
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
    while(1) 
    {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
else if(obj.x)
    curleft += obj.x;
return curleft;
}

// **************************************************
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
    while(1)
    {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
else if(obj.y)
    curtop += obj.y;
return curtop;
}

// **************************************************************************************
// AJAX
// **************************************************************************************

function httpGetObject() {

	var req;

    if(window.XMLHttpRequest && !(window.ActiveXObject))
    {
    	try 
    	{
			req = new XMLHttpRequest();
        } 
        catch(e)
        {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } 
    else if(window.ActiveXObject)
    {
    	try 
    	{
        	req = new ActiveXObject("Msxml2.XMLHTTP");
    	} 
    	catch(e) 
    	{
       		try 
       		{
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) 
        	{
          		req = false;
        	}
		}
    }

  return req;
}

function httpRequestData(oHTTP, sEventHandler, sURL, sMethod, params) {
		
	if (oHTTP)
	{
		oHTTP.open(sMethod, sURL, true);
	
		if (params)
		{
			oHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			oHTTP.setRequestHeader("Content-length", params.length);
			oHTTP.setRequestHeader("Connection", "close");
		}

		oHTTP.onreadystatechange = sEventHandler;
		
		oHTTP.send(params);
	}
  
}

function GetDistrictList(selectedValue, districtSelected, divID, langAbbr) {
		
	new Ajax.Request('../admin/district-dropdown.php',
		{ 	method: 'get',
			parameters: {cid: selectedValue, id: districtSelected, langSelect: langAbbr},
			onSuccess: function(transport) {
					var divElem = document.getElementById(divID);
					if (divElem) {						
						divElem.innerHTML = transport.responseText;
					}
				} 
		});
}

function GetInfoCategoriesList(selectedValue, categorySelected, divID) {
		
	new Ajax.Request('../admin/info-categories-dropdown.php',
		{ 	method: 'get',
			parameters: {secid: selectedValue, id: categorySelected},
			onSuccess: function(transport) {
					var divElem = document.getElementById(divID);
					if (divElem) {						
						divElem.innerHTML = transport.responseText;
					}
				} 
		});
}

function UpdateContent(elementID, urlString, params, showLoading) {
	
	new Ajax.Request(urlString,
		{ 	method: 'get',
			parameters: params,
			onLoading: function() {
					if (showLoading) {
						var divElem = document.getElementById(elementID);
						if (divElem) {						
							divElem.innerHTML = '<div style="text-align:center"><img src="../images/loading_new.gif" width="33" border="0"></div>';
						}
					}
				},
			onSuccess: function(transport) {
					var divElem = document.getElementById(elementID);
					if (divElem) {						
						divElem.innerHTML = transport.responseText;
					}
				} 
		});		
}

function SearchForIndutry(elementID, urlString, params, showLoading) {
	
	new Ajax.Request(urlString,
		{ 	method: 'get',
			parameters: params,
			onLoading: function() {
					if (showLoading) {
						var divElem = document.getElementById(elementID);
						if (divElem) {						
							divElem.innerHTML = '<div style="text-align:center"><img src="../images/loading_new.gif" width="33" border="0"></div>';
						}
					}
				},
			onSuccess: function(transport) {
					var divElem = document.getElementById(elementID);
					if (divElem) {						
						divElem.innerHTML = transport.responseText;
					}
				} 
		});		
}

function UpdateIndustryCheck(checkboxElem, IndustryID) {
	var industriesChecboxes = document.getElementsByName('Industries[]');
	for (i = 0; i < industriesChecboxes.length; i ++) {
		if (industriesChecboxes[i].value == IndustryID) {
			if (checkboxElem.checked) {
				industriesChecboxes[i].checked = true;
			} else {
				industriesChecboxes[i].checked = false;
			}
		}
	}
}

function AlertResult(urlString, params) {
	
	new Ajax.Request(urlString,
		{ 	method: 'get',
			parameters: params,
			onSuccess: function(transport) {
					if (transport.responseText != "") {
						alert(transport.responseText);
					}
				} 
		});		
}

// **************************************************************************************
// AJAX
// **************************************************************************************

// End hiding script from old browsers -->