window.onerror = OnError;
function OnError(msg, url, line){
	return(true);
}

function GetData(id){
	var content = document.getElementById(id);
	if(content == null)
	return("");
	return(content.innerHTML);
}

function Print(printPage, id, title){
	if(title == ''){
	title = document.title;
	var url = printPage + "?id=" + id + "&title=" + title
	var p = window.open(url, "print", "width=610, height=600, left=100, top=100, scrollbars=yes , location=no, menubar=no, resizable=no, status=no, toolbar=no, fullscreen=no");
	}
}

function PrintThisPage(id, printId){
	var content = document.getElementById(printId);
	if(content == null)
	return;
	if(window.opener == null)
	return;
	var html = window.opener.GetData(id);
	html = DisableHyperlinks(html);
	content.innerHTML = html;
	window.print();
}

function signup(url){
	var email = document.newsletter.txtNewsletter.value;
	if(email == '') {
		document.newsletter.txtNewsletter.focus();
		return false;
	} else {
		if(!isValidEmail(email)) {
			document.newsletter.txtNewsletter.focus();
			return false;
		}
	}
	var params = 'emailid=' + email;
	url = url + '?' + params;
	window.location=url;
	return false;
}


function DisableHyperlinks(html)
{
	return(html.replace(/href\s*=\s*\"*[^\">]*"/ig,"href=\"#\""));
}
function Email(url)
{
	url = url + "&page_title=" + document.title;
	var p = window.open(url, "email", "width=500, height=500, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, fullscreen=no");
}

function isValidEmail(str) {
	filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return(filter.test(str));
}

function MM_preloadImages() {
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function toggleTextOut(e,txtval) {
	if(e.value=="") e.value = txtval;

}
function toggleTextIn(e,txtval) {
	if(e.value==txtval) e.value="";
	else e.select();
}

function AllowOnly(e,type,allow_space){
	if (allow_space==null) allow_space=false; else allow_space=true;
	if(e.charCode==0) return true;
	var unicode=e.charCode? e.charCode : e.keyCode;
	if(allow_space && unicode==32)
	return true;
	switch(type)
	{
		case 'NUM_ONLY':
		if(unicode < 48 || unicode > 57) return false; else return true;
		case 'ALPHA_ONLY':
		if(unicode <65 || unicode >90)
		if(!(unicode >= 97 && unicode <=122))
		return false;
		else
		return true;
		case 'ALPHA_NUM_ONLY':
		if(unicode >= 65 && unicode <= 90)
		return true;
		if(unicode >= 97 && unicode <= 120)
		return true;
		if(unicode >= 48 && unicode <= 57)
		return true;
		else
		return false;

	}
}



function validate_newsletter_form(frm)
{
	if(!isValidEmail(frm.txtEmail.value))
	{
		alert('Pleases enter a valid email id');
		frm.txtEmail.focus();
		return false;
	}
	return true;
}

function makeRequest(url,id) {

	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange = function() { traffic(http_request,id); };
	http_request.open('GET', url, true);
	http_request.send(null);

}

function traffic(http_request,id) {

	if (http_request.readyState == 4) {
		document.getElementById(id).innerHTML = "";
		if (http_request.status == 200) {
			document.getElementById(id).innerHTML =  http_request.responseText;
			if(id=='content'){
				fadeEffect('content',0,100,500);
			}

		} else {
			alert('There was a problem with the request.');
		}
	}

}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
		{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}



function toggleProjectTowers()
{
	var frm=document.frmcontact; //frmcontact is the name of Contact us form
	var item=[];
	item=document.getElementById('sub-towers');
	item.style.display=(!frm.project_Towers.checked)? 'none' : '';
}

function makeTowersChecked()
{
	var frm=document.frmcontact; //frmcontact is the name of Contact us form
	frm.project_Towers.checked=true;
}

function changeSpotlight(url_path,spotlight) {
	if(spotlight.indexOf('.') == -1 ){
		var fo = new FlashObject(url_path + '/wp-content/files/Flash/' + spotlight + '.swf', "spotlight", "759", "321", "7", "#000000");
		fo.write("spotlight");
	}
	else {
		document.getElementById('spotlight').innerHTML = '<img src="' + url_path + '/wp-content/files/Image/' + spotlight + '" alt= ""  width="759" height="321" />';

	}
}


function getSuitableWindowSize(width,height)
{
	size=new Object();
	size.width=(width > screen.width - 50) ? screen.width - 50  : width;
	size.height=(height > screen.height - 80) ? screen.height - 80 : height;
	size.left=((screen.width - size.width) / 2 ) - 10;
	size.top=((screen.height - size.height) /2 ) - 20;
	if((width + 50)>screen.width || (height + 80) > screen.height) size.scrollbars='yes';
	return size;
}

function openImageWindow(width,height,url,title)
{
	size=getSuitableWindowSize(width,height);
	wind_params="status=0,menubar=0,resizable=no, menubar=no, toolbar=no,height="+size.height+",width="+size.width+",left="+size.left+",top="+size.top+",scrollbars="+size.scrollbars;
	window.open(url,title,wind_params);
}

function getElementsByClass(oElm, strTagName, strClassName){
	oElm=document.getElementById(oElm);
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function closeOthers(curr)
{
	var arrElements=getElementsByClass('sidebar-right','li','current');
	if(arrElements)
	{
		for(i=0; i<arrElements.length; i++)
		{
			arrElements[i].className='';
		}
	}
	var item=fGetElementById(curr);
	if(item)
	{
		item.className = 'current';
	}
	fMenu('related-links', 'current');
	fix();
}

function fix()
{
	var arrElements=getElementsByClass('sidebar-right','li','current');
	if(arrElements)
	{
		for(i=0; i<arrElements.length; i++)
		{
			if(arrElements[i].className=='current') { arrElements[i].className=''; }
		}
	}
}

function highlight(id)
{
	var arrElements=getElementsByClass('sidebar-right','li','current');
	if(arrElements)
	{
		for(i=0; i<arrElements.length; i++)
		{
			if(arrElements[i].className=='current') { arrElements[i].className=''; }
		}
	}

	var item=document.getElementById(id);

	if(item)
	{
		item.className = 'current';
	}
	fMenu('related-links', 'current');
}

function doAjax()
{
}

getViewportScrollX = function() {
	var scrollX = 0;
	if( document.documentElement && document.documentElement.scrollLeft ) {
		scrollX = document.documentElement.scrollLeft;
	}
	else if( document.body && document.body.scrollLeft ) {
		scrollX = document.body.scrollLeft;
	}
	else if( window.pageXOffset ) {
		scrollX = window.pageXOffset;
	}
	else if( window.scrollX ) {
		scrollX = window.scrollX;
	}
	return scrollX;
};

getViewportScrollY = function() {
	var scrollY = 0;
	if( document.documentElement && document.documentElement.scrollTop ) {
		scrollY = document.documentElement.scrollTop;
	}
	else if( document.body && document.body.scrollTop ) {
		scrollY = document.body.scrollTop;
	}
	else if( window.pageYOffset ) {
		scrollY = window.pageYOffset;
	}
	else if( window.scrollY ) {
		scrollY = window.scrollY;
	}
	return scrollY;
};
getViewportWidth = function() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth - 18;
	}
	return width;
};

getViewportHeight = function() {
	var height = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight - 18;
	}
	return height;
};

function getWindowSize()
{
	var wndSize=new Object();
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			wndSize.width= document.body.offsetWidth-20;
			wndSize.height= document.body.offsetHeight-20;
		}
		else {
			wndSize.width = window.innerWidth-16;
			wndSize.height = window.innerHeight-16;
		}

	}
	return wndSize;
}

function getElementsByClass(oElm, strTagName, strClassName){
	/*oElm=document.getElementById(oElm);*/
	var arrElements = (strTagName == "*" && document.all)? document.all : document.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
function expandCollapse(){
	var els=getElementsByClass('content','*','expand');
	for(i=0;i < els.length; i++) {
		els[i].onclick = function() {
			this.className = this.className=='expand' ? 'collapse' : 'expand';
		}
	}
	var els=getElementsByClass('content','*','collapse');
	for(i=0;i<els.length;i++) {
		els[i].onclick=function() {
			this.className = this.className=='expand' ? 'collapse' : 'expand';
		}
	}

}
window.onload = function () {  expandCollapse(); fMenu('related-links','current'); }