// ALL JavaScript Documents

// JavaScript Document - General_js


function go() {
loc=document.getElementById('urlAddress').value;
if (loc == "") return false;
if (document.getElementById('winLoc').checked == true) var win = window.open(loc);
else location.href=loc;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// All Center Search Javascript

// JavaScript Document Google Custom javascript

function google_toggleTab ( searchType, qcat, idName ){
	var tabs = document.getElementsByTagName('a');

	for( var i=0; i<tabs.length; i++ ){
		var tabi = tabs[i];
		if ( tabi.id == idName && tabi.className == "google_tabInactive" ){ tabi.className="google_tabActive";}
		else if ( tabi.id == idName && tabi.className=="google_tabActive" ){ tabi.className="google_tabActive";}
		else if ( tabi.className=="google_tabActive" ){ tabi.className="google_tabInactive";}
	}
	
	if (searchType == "Web")document.forms[0].action = "http://www.google.gr/custom";
	if (searchType == "Image")document.forms[0].action = "http://images.google.com/images";
	if (searchType == "Video")document.forms[0].action = "http://video.google.com/videosearch";
	if (searchType == "News")document.forms[0].action = "http://news.google.com/";
	if (searchType == "Maps")document.forms[0].action = "http://maps.google.com/maps";
	if (searchType == "Blogs")document.forms[0].action = "http://blogsearch.google.com/blogsearch";
	if (searchType == "Books")document.forms[0].action = "http://books.google.com/books";
	
}

// JavaScript Document Yahoo javascript

function yahoo_toggleTab ( searchType, qcat, idName ){
	var tabs = document.getElementsByTagName('a');

	for( var i=0; i<tabs.length; i++ ){
		var tabi = tabs[i];
		if ( tabi.id == idName && tabi.className == "yahoo_tabInactive" ){ tabi.className="yahoo_tabActive";}
		else if ( tabi.id == idName && tabi.className=="yahoo_tabActive" ){ tabi.className="yahoo_tabActive";}
		else if ( tabi.className=="yahoo_tabActive" ){ tabi.className="yahoo_tabInactive";}
	}
	
	if (searchType == "Web")document.forms[0].action = "http://search.yahoo.com/search";
	if (searchType == "Image")document.forms[0].action = "http://images.search.yahoo.com/search/images";
	if (searchType == "Video")document.forms[0].action = "http://video.yahoo.com/video/search?";   
	if (searchType == "Maps")document.forms[0].action = "http://maps.yahoo.com/flash/"
	if (searchType == "Maps")document.forms[0].p.name = "q1"
	    else (document.forms[0].p.name = "p");
	if (searchType == "Audio")document.forms[0].action = "http://audio.search.yahoo.com/search/audio";
	
}

// JavaScript Document Google javascript

function msn_toggleTab ( searchType, qcat, idName ){
	var tabs = document.getElementsByTagName('a');

	for( var i=0; i<tabs.length; i++ ){
		var tabi = tabs[i];
		if ( tabi.id == idName && tabi.className == "msn_tabInactive" ){ tabi.className="msn_tabActive";}
		else if ( tabi.id == idName && tabi.className=="msn_tabActive" ){ tabi.className="msn_tabActive";}
		else if ( tabi.className=="msn_tabActive" ){ tabi.className="msn_tabInactive";}
	}
	
	if (searchType == "Web")document.forms[0].action = "http://search.live.com/results.aspx";
	if (searchType == "Image")document.forms[0].action = "http://search.live.com/images/results.aspx";
	if (searchType == "Video")document.forms[0].action = "http://search.live.com/video/results.aspx";   
	if (searchType == "Maps")document.forms[0].action = "http://maps.live.com/";
	if (searchType == "News")document.forms[0].action = "http://search.msn.com/news/results.aspx";
	
}

// JavaScript Document Web Crawler javascript

var advsrchterms = "&&amp;msShowTOU=0";
		
		function urlEncode (str) {
			var estr = escape( str );
			estr = estr.replace(/@/g, '%40');
			estr = estr.replace(/\*/g,'%2A');    
			estr = estr.replace(/_/g, '%5F');    
			estr = estr.replace(/\+/g,'%2B');    
			estr = estr.replace(/\./g,'%2E');    
			estr = estr.replace(/\//g,'%2F');
			return estr;    
		}

		function clearadvanced() {
			if(document.idxSearch.exact){
				if(!document.idxSearch.exact.checked)
					var exact = '';
					advsrchterms = '';
			}
		}
		
		function redirSearch ( qcat ) {
			location.href = 'http://www.webcrawler.com/info.wbcrwl/search/index.htm?qcat=' + qcat;
		}
		
		
		function toggleTab ( searchType, qcat, idName ) {
			
			
			if ( document.idxSearch ) document.idxSearch.qcat.value = qcat;
			if ( document.idxSearchbot ) document.idxSearchbot.qcat.value = qcat;
			
			
			var tabs = document.getElementsByTagName('a');
			for( var i=0; i<tabs.length; i++ ) {
				var tabi = tabs[i];
				
				if ( tabi.id == idName && tabi.className == "tabInactive" ) {
					tabi.className="tabActive";	
				} else if ( tabi.id == idName && tabi.className=="tabActive" ) {
					tabi.className="tabActive";
				} else if ( tabi.className=="tabActive" ) {
					tabi.className="tabInactive";
				}
			}
			
			
			var thehtml = '<a class="Text-On-Tablestyle-BG1" href="http://msxml.webcrawler.com/info.wbcrwl/search/advanced/' + searchType.toLowerCase() + '.htm?&amp;msShowTOU=0&amp;r_fcid=414&amp;r_fcp=top&amp;dpcollation=1&amp;qk=20&amp;familyfilter=0&amp;sort=0&amp;adultfilter=moderate&amp;msShowTOU=0">Advanced ' + searchType + ' Search</a>';
			if ( document.getElementById("advancedlink") ) document.getElementById("advancedlink").innerHTML = thehtml;
			if ( document.getElementById("advancedlinkbot") ) document.getElementById("advancedlinkbot").innerHTML = thehtml;

			
			var img = new Image();
			img.src = "http://msxml.webcrawler.com/info.wbcrwl/search/5_5/logging/category.htm?category=" + searchType + "&ran=" + Math.round(Math.random()*10000);

		}


// JavaScript Document Google javascript

function ingr_toggleTab ( searchType, qcat, idName ){
	var tabs = document.getElementsByTagName('a');

	for( var i=0; i<tabs.length; i++ ){
		var tabi = tabs[i];
		if ( tabi.id == idName && tabi.className == "ingr_tabInactive" ){ tabi.className="ingr_tabActive";}
		else if ( tabi.id == idName && tabi.className=="ingr_tabActive" ){ tabi.className="ingr_tabActive";}
		else if ( tabi.className=="ingr_tabActive" ){ tabi.className="ingr_tabInactive";}
	}
	
	if (searchType == "Pathfinder")document.forms[0].action = "http://search.pathfinder.gr/search";
	if (searchType == "Ingr")document.forms[0].action = "http://www.in.gr/directory/search.asp";
	if (searchType == "Ingr")document.forms[0].q.name = "WordsAll"
	    else (document.forms[0].q.name = "q");
	if (searchType == "Forthnet")document.forms[0].action = "http://dir.forthnet.gr/";	
	if (searchType == "Weboffice")document.forms[0].action = "http://www.web-office.gr/search.php";
	if (searchType == "Weboffice")document.forms[0].q.name = "keyword"
	    else (document.forms[0].q.name = "q");
	
}


// Ajax Tabs Javascript

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadstatustext="<img src='scripts_s/ajaxtabs/loading.gif' /> Requesting content..."

////NO NEED TO EDIT BELOW////////////////////////
var loadedobjects=""
var defaultcontentarray=new Object()
var bustcacheparameter=""

function ajaxpage(url, containerid, targetobj){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
var ullist=targetobj.parentNode.parentNode.getElementsByTagName("li")
for (var i=0; i<ullist.length; i++)
ullist[i].className=""  //deselect all tabs
targetobj.parentNode.className="selected"  //highlight currently clicked on tab
if (url.indexOf("#default")!=-1){ //if simply show default content within container (verus fetch it via ajax)
document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
return
}
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(revattribute){
if (revattribute!=null && revattribute!=""){ //if "rev" attribute is defined (load external .js or .css files)
var objectlist=revattribute.split(/\s*,\s*/) //split the files and store as array
for (var i=0; i<objectlist.length; i++){
var file=objectlist[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel")){
ajaxpage(thetab.getAttribute("href"), thetab.getAttribute("rel"), thetab)
loadobjs(thetab.getAttribute("rev"))
}
}

function savedefaultcontent(contentid){// save default ajax tab content
if (typeof defaultcontentarray[contentid]=="undefined") //if default content hasn't already been saved
defaultcontentarray[contentid]=document.getElementById(contentid).innerHTML
}

function startajaxtabs(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
ulistlink.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
savedefaultcontent(ulistlink.getAttribute("rel")) //save default ajax tab content
ulistlink.onclick=function(){
ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)
loadobjs(this.getAttribute("rev"))
return false
}
if (ulist[x].className=="selected"){
ajaxpage(ulistlink.getAttribute("href"), ulistlink.getAttribute("rel"), ulistlink) //auto load currenly selected tab content
loadobjs(ulistlink.getAttribute("rev")) //auto load any accompanying .js and .css files
}
}
}
}
}
