function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM2_swapImgRestore(object) { //v3.0
  if (object && object.childNodes) {
	var img = object.childNodes[0];
	if (img && img.src && img.oSrc) {
		img.src = img.oSrc;		
	}
  }
}


function getY(obj) {
	var Y = 0;
	var tmp = obj;
	while (tmp) {
		Y += tmp.offsetTop;
		tmp = tmp.offsetParent;
	}
	return Y;
}

function getX(obj) {
	var X = 0;
	var tmp = obj;
	while (tmp) {
		X += tmp.offsetLeft;
		tmp = tmp.offsetParent;
	}
	return X;
}

var timeouts = {};
var dims = {
	"location_map": 163,
	"download_map": 163,
	"project_map": 186,
	"arlocation_map": 183,
	"ardownload_map": 163,
	"arproject_map": 183
};

var IE = document.all;

function D(n) { return document.getElementById(n); }

function show(self, div) {

	cancelhide(div);
	var obj = document.getElementById(div);
	var y = getY(self);
	var extra = IE ? -18 : 0;
	obj.style.top = (y - dims[div] - extra - 1) + "px";
	obj.style.display = "block";
}

function quickhideall() {
	MM2_swapImgRestore(this);
	try {
		var obj = document.getElementById("location_map");
		obj.style.display = "none";
		obj = document.getElementById("project_map");
		obj.style.display = "none";
		
		obj = document.getElementById("download_map");
		obj.style.display = "none";
		
		
	} catch (ex) {}
	try {
		var obj = document.getElementById("arlocation_map");
		obj.style.display = "none";
		obj = document.getElementById("arproject_map");
		obj.style.display = "none";
		obj = document.getElementById("ardownload_map");
		obj.style.display = "none";
		
		

	} catch (ex) {}
	
	var img   = document.getElementById("projectmap");
	if (img && img.src && img.oSrc) img.src = img.oSrc;
	img   = document.getElementById("locationmap");
	if (img && img.src && img.oSrc) img.src = img.oSrc;
	img   = document.getElementById("downloadmap");
	if (img && img.src && img.oSrc) img.src = img.oSrc;
	
	
	
	
}

function delayhide(div) {

	var img = document.getElementById(div.split("_").join(""));
	timeouts[div] = setTimeout( function() {
		var obj = document.getElementById(div);
		obj.style.display = "none";
		try { img.src = img.oSrc; } catch(ex) {}
		//MM2_swapImgRestore(this);
	}, 1000);
}

function cancelhide(div) {
	clearTimeout(timeouts[div]);
}

function siteroll(obj) {
	
	var td = obj.offsetParent;
	
	td.className = "sitedevover"
}

function siteunroll(obj) {
	var td = obj.offsetParent;
	if (td.dis) return;
	td.className = "sitedev"
}



function siteopen(obj, id) {
	var td = document.getElementById("td" + id);
	td.className = "sitedevover";
	td.dis = true;
	document.getElementById(id).style.display = "block";
	window.scrollTo(0, getY(document.getElementById(id)) - 100 );
	
	populate_thumbs(id);	
	moopic(id);
}

function siteclose(id) {
	document.getElementById(id).style.display = "none"
}

function rightpic(id) {
	var cnt = devscrolls[id];

	cnt++;
	if (cnt > devgallery[id].length - 8) {
		cnt = devgallery[id].length - 8;	
	}
	devscrolls[id] = cnt;
	populate_thumbs(id);
}

function leftpic(id) {
	var cnt = devscrolls[id];
	cnt--;
	if (cnt < 0) {
		cnt = 0;	
	}
	devscrolls[id] = cnt;
	populate_thumbs(id);
}

function populate_thumbs(id) {
	var gal = devgallery[id];
	var html = "";
	
	for (var i=devscrolls[id]; i < devscrolls[id] + 8 && i < gal.length; i++) {
		html += render_thumb(id, i, gal[i].thumb);
	}
	
	D("thumbs" + id).innerHTML = html;		
}

function render_thumb(id, n, src) {
	var html = "";
	
	html += '<a style="margin-left: 1px" href="javascript:void(setpic(' +"'" + id  +"'" + ',' + n + '))"><img src="' + src + '" border="0" width=67 height=48 /></a>';
	
	return html;
}

function setpic(id, n) {
	devcurrents[id] = n;
	moopic(id);
}

function moopic(id) {
	var gal = devgallery[id][devcurrents[id]];
	
	document.getElementById("pic"+id).innerHTML = '<img src="'+gal.pic+'" width="581" height="419"  />';
	document.getElementById("content"+id).innerHTML = gal.text;
	document.getElementById("title"+id).innerHTML = gal.title;
}

function mv(a, div) {
	D(div).style.display = 'block';
	
	D(div).style.left = (getX(a) - 3) + "px";
	D(div).style.top = (getY(a) + 5) + "px";
}

function amv(a, div) {
	D(div).style.display = 'block';
	
	
	
	D(div).style.left = (getX(a) + a.offsetWidth ) + "px";
	D(div).style.top = (getY(a) + 5) + "px";
}


function rm(div) {
	D(div).style.display = 'none';
}


function poptastic2(hisname,patho,loca)
		{
		newwindow=window.open("blank.html",hisname,'height=110,width=450,scrollbars=no,toolbar=0,menubar=0,status=no,directories=no,');
		if (window.focus) {newwindow.focus()}
			newwindow.document.style
			var str='<html><head><script type="text/JavaScript" src="../static/js/scripts.js"></script></head><body style="margin:0px;" onload="MM_preloadImages(\'static/images/r_snd.gif\')">';
                str+='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#133330">';
                          str+='<form action="../refertofriend.aspx" name="frmref" method="post" onsubmit=""><input type="hidden" name="loc" value="'+loca+'" /><tr>';
                         str+='   <td width="118" rowspan="3" valign="top"><img src="../static/images/email.gif" width="118" height="110" /></td>';
                         str+='   <td width="248" height="41">&nbsp;</td>';
                         str+='   <td width="84" rowspan="3" valign="top"><a href="javascript:checkandclose(document.frmref);" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'Image2\',\'\',\'../static/images/r_snd.gif\',1)"><img src="../static/images/snd.gif" name="Image2" width="84" height="110" border="0" id="Image2" /></a></td>';
                         str+=' </tr>';
                          str+='<tr>';
                           str+=' <td width="248" valign="top" height="21"><input type="text" name="txtfriend" style="width:248px;height:24px;background-color:#5a716f;color:#ffffff;font-family:Verdana;font-size:12px;border:0px;" /></td>';
                          str+='</tr>';
                          str+='<tr>';
                           str+=' <td width="248" height="38">&nbsp;</td>';
                          str+='</tr>';
                        str+='</form></table>';
                        str+='</body></html>';			
			newwindow.document.write(str);
			newwindow.document.close();
		}
function poptastic3(hisname,patho,loca)
		{
		newwindow=window.open("blank.html",hisname,'height=110,width=450,scrollbars=no,toolbar=0,menubar=0,status=no,directories=no,');
		if (window.focus) {newwindow.focus()}
			newwindow.document.style
                var str='<html>';
                str+='<head>';
                str+='<script type="text/JavaScript" src="../static/js/scripts.js"></script>';
                str+='</head>';
                str+='<body style="margin:0px;" onLoad="MM_preloadImages(\'../static/images/r_ar_snd.gif\')">';
                str+='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#133330">';
                  str+='<form action="../refertofriend.aspx" name="frmref" method="post">';
                    str+='<input type="hidden" name="loc" value="" />';
                    str+='<tr>';
                      str+='<td width="84" rowspan="3" valign="top" height="110"><a href="javascript:checkandclose(document.frmref);" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Image2\',\'\',\'../static/images/r_ar_snd.gif\',1)"><img src="../static/images/ar_snd.gif" name="Image2" width="84" height="110" border="0"></a></td>';
                      str+='<td width="248" height="41" >&nbsp;</td>';
                      str+='<td width="118" rowspan="3" valign="top" height="110"><img src="../static/images/ar_email.gif" width="118" height="110"></td>';
                    str+='</tr>';
                    str+='<tr>';
                     str+= '<td width="248" valign="top" height="21"><input type="text" name="txtfriend" style="width:248px;height:24px;background-color:#5a716f;color:#ffffff;font-family:Verdana;font-size:12px;border:0px;" /></td>';
                    str+='</tr>';
                    str+='<tr>';
                    str+= ' <td width="248" height="38">&nbsp;</td>';
                   str+= '</tr>';
                  str+='</form>';
                str+='</table>';
                str+='</body>';
                str+='</html>';
			
			
			newwindow.document.write(str);
			newwindow.document.close();
		}


         function check_email(email_txt){
                emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;              
                if(emailRegExp.test(email_txt)){
                    //alert('true');
                    return true;
               }else{

                 //alert('false');
                  return false;
             }
         }

function submit_form(objform){
	with(objform){
		if(txtemail.value==""){
			alert("please enter your email");	
			return;
		}
		if(check_email(txtemail.value)==false){
			alert("please enter a valid  email");	
			return;			
			
		}
		if(txtcv.value==""){
		
			alert("please attach your cv");	
			return;				
		}
		if(txtcity.value==""){
			alert("please enter your city");	
			return;
		}
		if(txtmobile.value==""){
			alert("please enter your mobile");	
			return;
		}
		if(txtpobox.value==""){
			alert("please enter your po.box");	
			return;
		}		
		objform.submit();
		
	
		
	}
	
	}
	
	
	function checkandclose(objform){
		with(objform){
			if(txtfriend.value==""){
				alert("please enter your email");	
				return;
			}
			if(check_email(txtfriend.value)==false){
				alert("please enter a valid  email");	
				return;			
				
			}			
		}
		objform.submit();
		window.close();
		
	}
		

