/*
//Author        : canegem bilisim,
//Functionality : closes the existing window and open a full size window with the passed url.
//		  Used in video pop up's
*/

var newwindow = ''
function popitup(url,name,wth,ht) {
if (newwindow.location && !newwindow.closed )
{
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,name,'width='+wth+',height='+ht+',resizable=1');} 
     }
function closeall() {
if (newwindow.location && !newwindow.closed) { 
   newwindow.close(); } 
}


function popUp(URL) {
var high = screen.height;
var wide = screen.width;
wopen = window.open(URL, 'send_to_friend', 'left=0, top=0, location=yes,toolbar=yes,menubar=yes,directories=yes,status=yes,resizable=yes,scrollbars=yes,height='+high+',width='+wide+',left=0');
window.close();  
wopen.focus();
}  

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_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_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 setFieldValue(fieldRef, str) {
	// clears field when user clicks in, 
	// and resets to default str when user clicks out 
	// with no value in the field.
	obj = eval(fieldRef);
	if (obj.value == str) {
		obj.value = "";
	}
	else if (obj.value == "") {
		obj.value = str;
	}
}

function ieW() {
	if (navigator.appName.indexOf('Microsoft Internet Explorer') == 0) {
		var Ps = document.getElementsByTagName('P');
		var TDs = document.getElementsByTagName('TD');
		if (Ps) {
			for (a=0; a<Ps.length; a++) {
				if (Ps[a].firstChild != null) {				
					if (Ps[a].firstChild.nodeName == '#text') {
						var para = Ps[a].firstChild.nodeValue;
						if (para.indexOf('W') == 0) {
						Ps[a].className='fixW';
						}
					}
					else if (Ps[a].firstChild.nodeName == 'EM'){
						var emph = Ps[a].firstChild
						if (emph.firstChild.nodeName == '#text') {
						var emphText = emph.firstChild.nodeValue;
							if (emphText.indexOf('W') == 0) {
							Ps[a].className='fixW';
							}
						}
					}  
				}
			}
		}
		if (TDs) {
			for (a=0; a<TDs.length; a++) {
				if (TDs[a].firstChild != null) {				
					if (TDs[a].firstChild.nodeName == '#text' && TDs[a].className != ''){
						var para = TDs[a].firstChild.nodeValue;
						if (para.indexOf('W') == 0) {
						TDs[a].className='fixW';
						}
					}
				}
			}
		}
	}
}

function getHeights() {

	
	var nav = document.getElementById('nav2');
	var bodyHead = document.getElementById('bodyHead');
	var col1 = document.getElementById('col1');
	if (findElement('col2')) {
		var col2 = document.getElementById('col2');}
	else {
		var col2 = document.getElementById('col1');}

	if (bodyHead && col1 && col2) {
		var navHeight = nav.offsetHeight;
		var bodyHeadHeight = bodyHead.offsetHeight;
		var col1Height = col1.offsetHeight;
		var col2Height = col2.offsetHeight;
		
		
		
		if (col1Height > col2Height) {
		var bodyHeight = col1Height;
		}
		else {
		var bodyHeight = col2Height;
		}
	
		
		var combinedHeight = bodyHeight + bodyHeadHeight;
		if (combinedHeight < navHeight) {
		
		var gap = navHeight - combinedHeight;
			if (col1Height > col2Height) {
				col1.style.height = col1Height + gap + 'px';
			}
			
			if (col1Height < col2Height) {
				col2.style.height = col2Height + gap + 'px';
			}		
			else {
				col2.style.height = col2Height + gap + 'px';
	
			}
		}
	}
}



function findElement(colName) {
	var eleNo = document.getElementsByTagName('DIV');
	for (i=0;i<eleNo;i++) {
		if (document.all[i].id==colName) {
			return true;
		}
	}
	return false;
}

//UTF-8 encoding Functions required for Search functionality. Added by Surendra on 11/04/2005.

var okURIcharsCopy = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ \"-";
var hexcharsCopy = "0123456789ABCDEF";
function encodeURIComponentNewCopy(s) {  if(s==null || s.length<=0)  	return s;  var s = utf8Copy(s);  var c;  var enc = "";  for (var i= 0; i<s.length; i++) {    if (okURIcharsCopy.indexOf(s.charAt(i))==-1)      enc += "%"+toHexCopy(s.charCodeAt(i));    else      enc += s.charAt(i);  }  return enc;}

function utf8Copy(wide) {  var c, s;  var enc = "";  var i = 0;  while(i<wide.length) {    c= wide.charCodeAt(i++);        if (c>=0xDC00 && c<0xE000) continue;    if (c>=0xD800 && c<0xDC00) {      if (i>=wide.length) continue;      s= wide.charCodeAt(i++);      if (s<0xDC00 || c>=0xDE00) continue;      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;    }        if (c<0x80) enc += String.fromCharCode(c);    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));  }  return enc;}

function toHexCopy(n) {  return hexcharsCopy.charAt(n>>4)+hexcharsCopy.charAt(n & 0xF);}

function submitSearch() {
	document.searchForm.textToSearch.value = encodeURIComponentNewCopy(document.searchForm.homeSearch.value);
	document.searchForm.submit();
}
