function searchprovider( url ) {
	if( url.indexOf('daemon-search') > -1 ) {
		root = 'daemon-search';
		path = '';
	} else if( url.indexOf('astroburn-search') > -1 ) {
		root = 'astroburn-search';
		path = '';
	} else {
		root = 'xngq';
		path = 'baidu/';
	}
	window.external.AddSearchProvider('http://www.' + root + '.com/' + path + 'opensearch-' + root + '.xml');
}

function bookmark(url,title,add2favor) {
	if( ( window.opera && window.print ) || navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ) {
		document.getElementById('addbookmark').style.display = 'block';
	}else if(window.sidebar) {
		window.sidebar.addPanel(title,url,"", false);
	} else if(document.all) {
		window.external.AddFavorite(url,title);
	}
}

function addon(url,title,add2favor,add2searchp){
	fname = '';
	if( '\v'=='v' ) {
		fname = navigator.userAgent.indexOf('IE 7') != -1 || navigator.userAgent.indexOf('IE 8') != -1 ? 'searchprovider' : 'bookmark';
	} else if( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ) {
		fname = 'bookmark';
	} else if( window.sidebar ) { // FF
		fname = 'searchprovider';
	} else if( window.opera && window.print ) {
		fname = '';
	}
	linktext = fname == 'bookmark' || fname == '' ? add2favor : add2searchp;
	if( fname != '' ) {
		url = "'" + url + "'";
		title = "'" + title + "'";
		document.write( '<a href="javascript:' + fname + '(' + url + ',' + title + ')" class="white normal">+ ' + linktext + '</a>' );
	} else {
		document.write( '<a href="' + url + '" rel="sidebar" title="' + title + '" class="white normal">+ ' + linktext + '</a>' );
	}
}

function addClass(element, value) {
	if (!element.className) {
		element.className = value;
	} else {
		var newClassName = element.className;
		newClassName += " ";
		newClassName += value;
		element.className = newClassName;
	}
}

function setsearchaction(types,type,action) {
	var d = document;
	var ds = d.f;
	for(i=0;i<types.length;i++) {
		if(types[i] == type) d.getElementById(types[i]).className = 'selected';
		else d.getElementById(types[i]).className = '';
	}
	ds.action=action;
	ds.q.focus();
}
function screenWidth(){
	if(window.innerWidth){
		width = window.innerWidth;
		} else if(document.documentElement && document.documentElement.clientWidth){
		width = document.documentElement.clientWidth;
		} else if(document.body && document.body.clientWidth){
		width = document.body.clientWidth;
	}
	return width;
}
function moveadvancedsearch() {
	as_width = as.style.width;
	reg = /[a-z]/g;
	as_width = parseFloat( as_width.replace( reg, "" ) );
	as.style.left = Math.round( ( screenWidth( ) - as_width ) / 2 ) + 'px';
}
function setScreenImgWidth() {
	document.getElementById("scroll_independence").style.width = ( ( screenWidth( ) ) - 40)+"px";
	if( typeof( as ) != "undefined" ) {moveadvancedsearch();}
}
function sendRequest(){var d = document.webadvanced;if(d.q.value=='' && d.q0.value=='' && d.q1.value==''){d.q.focus();}else{d.submit();}}
document.onkeydown = keypress;
if( '\v' != 'v')
	document.captureEvents(Event.KEYDOWN);
function keypress(e) {
	var ua = navigator.userAgent.toLowerCase();
	var closeAS = false;
	var EscCode = 27;
	if( '\v' == 'v') {
		if( event.keyCode == EscCode )
			closeAS = true;
	} else if( ua.indexOf("opera") != -1 ) {
		if( event.keyCode == EscCode )
			closeAS = true;
	} else if( ua.indexOf("gecko") != -1 ) {
		if( e.which == EscCode )
			closeAS = true;
	}
	if( closeAS == true )
		if( document.getElementById('advancedsearch') != null )
			document.getElementById('advancedsearch').style.display='none';
}
/* GameCentrix */
function GCXsetImg( imgname, bname ) {
	document[imgname].src = 'http://img.daemon-search.com/' + bname;
}
function GCXonMouseOver( button ) {
	GCXsetImg( 'm' + button, 'gcx-' + button + '-button-over.gif' );
}
function GCXonMouseOut( button ) {
	GCXsetImg( 'm' + button, 'gcx-' + button + '-button.gif' );
}
function GCXshowimg( img ) {
	if( img == 'previous' ) {
		iGCX -= 1;
		if( iGCX < 0 )
			iGCX = countGCX - 1;
	} else {
		iGCX += 1;
		if( iGCX == countGCX )
			iGCX = 0;
	}
	GCXsetImg( 'gcximg', listGCXgame[iGCX]['img'] );
	document.getElementById('gcximg').title = listGCXgame[iGCX]['name'];
	document.getElementById('gcxhref').href = listGCXgame[iGCX]['url'];
	GCXonMouseOut( 'left' );
	GCXonMouseOut( 'right' );
}