function $$(id)
{
	return document.getElementById(id);
}
function showM(m){
	var oc = m.className;
	m.className=oc+" on";
}
function hideM(m){
	var oc = m.className;
	m.className=oc.replace("on","");
}
function onCheckQuickSearch()
{
	if($$('simple_search').value.trim()=='')
	{
		alert("Please enter search keywords.");
		return false;
	}
	return true;
}
/*******Begin Search ********************************/
function showAdvSearch(smodel)
{
	var url = "/search.php?act=adv_search"
	if(smodel) url += "&smodel="+smodel;
	Boxy.load(url, 
		{cache:true,modal: true,borderWidth:0,title:"Advanced Search",unloadOnHide:true,	afterShow:	function()
			{				
			}
		});
}
function onAdvanceSearchModelChange(o)
{
	$$('searchArticleOnly').style.display = 'none';
	$$('searchArtOnly').style.display = 'none';
	$$('searchALL').style.display = 'none';
	if(o.value =='article')
			$$('searchArticleOnly').style.display = '';
	if(o.value =='photo')
			$$('searchArtOnly').style.display = '';
	if(o.value =='all')
			$$('searchALL').style.display = '';
}
function validateAdvSearch(form)
{
	if( ($$('smodelradio0').checked && form.s_firstname.value.trim()=="" && form.s_lastname.value.trim()!="")
		||($$('smodelradio1').checked && form.sart_firstname.value.trim()=="" && form.sart_lastname.value.trim()!="")
		||($$('smodelradio2').checked && form.sall_firstname.value.trim()=="" && form.sall_lastname.value.trim()!="") )
	{
		alert("There are a lot of authors with the initial '" + (form.s_lastname.value||form.sart_lastname.value||form.sall_lastname.value) + "'.\nTo search by an author's last initial\nyou will also need to enter their first name.");
		return false;
	}
	return true;
}
/*******End Search ********************************/
function SetThisVoteOn(o)
{
	var divs = $$('block_vote').getElementsByTagName('div');
	var n = divs.length;
	for(var i=0;i <n; i++)
	{
		divs[i].className="A";	
	}
	o.className= "A on";
	var r = o.getElementsByTagName('input');
	r[0].checked = true;
}
function SetTopVoteValue(n)
{
	$$('hd_vote').value = n;
}
function SubmitTopVote()
{
	var url	= "/includes/star_rating/rating.php?j=5&q="+$('#block_vote input:checked').val()+"&top=1";
	$('#top_vote_result').load(url);	
}
function LoadPage(page)
{
	location.href=SetQuery('page',page);
}
function setPageSize(o)
{
	location.href=SetQuery('page_size',o.value);
}
function setOnlyPrinted(o)
{	
	location.href=SetQuery('only_printed',o.checked?'1':'0');
}
function GetNextArticleURL(id,next,cat,subcat,o)
{
	$(o).after("<img src='/images/loading.gif'>");
	$.post("/plus/works/get_next_article_url.php", { "id":id, "next":next, "cat":cat, "subcat":subcat},function(data){
		$(o).next("img").remove();
		if(data)
			location.href=data;
		else if(next>0)
			location.href="/"+cat+"/"+subcat+"/";
		else if(next<0)
			location.href="/"+cat+"/"+subcat+"/";
	});
}
function ShowHide(id1,id2)
{
	$$(id1).style.display='block';
	$$(id2).style.display='none';	
}
function SetOrder(order_by,order_type)
{
	var keys= ['order_by','order_type'];
	var values= [order_by,order_type];
	location.href=SetQuery(keys,values);
}
function gotoCategory(o,cat)
{
	if(o.value.indexOf("/")>-1)
	{		
		var url = o.value;
	}
	else
	{
		var url = location.href;	
		var reg = new RegExp(cat+"\/?[^\/]*","ig");
		url = url.replace(reg,cat+"/"+o.value);
		url = url.replace(/\?.*/g,'');
	}
	location.href = url;
}
function GetMoversShakersList(o)
{
	$(o).after("<img src='/images/loading.gif'>");
	$.post("/plus/works/get_movers_shakers_list.php", null,function(data){
		if(data)
		{
			$("#movers_shakers_list").fadeOut("normal",function(){
				$('#movers_shakers_list').html(data);
				$('#movers_shakers_list').fadeIn("slow");														  
			});
			
		}
		$(o).next().remove();
	});
	
}
function showLogin()
{	
	if(!$$('login_buttons'))
		return;
	Boxy.load("/account.php?act=login_popup", 
		{cache:false,modal: true,borderWidth:0,title:"Login",unloadOnHide:true});
}
function ClearPrompt(o)
{
	if(o.value==o.title)
	{
		o.value='';
		o.style.color="black";
	}
}
function SetPrompt(o)
{
	if(o.value=='')
	{
		o.value=o.title;
		o.style.color="gray";
	}
}
function trackUser(userid)
{
	if($('.track_user').find('img#track_loading').length==0)
		$('.track_user').append("<img src='/images/loading.gif' id='track_loading'>");
	$.ajax({
		url:'/account.php?act=user_watch&uid='+userid,
		dataType:'json',
		success:function(data){
			if(data.result>0)
			{
				$('.track_user').html(data.msg);
			}
			else if(data.msg)
			{
				alert(data.msg);
				$('.track_user').find('img#track_loading').remove();
			}
		},
		error:function()
		{
			alert("Oops... please check your internet connection.");
		}
	});
}
function check_fb_method_permission(m,callback)
{
	result = false
	var obj_ajax = new Ajax( '/account.php?act=fb_method_permision&method='+m, null, function(){
		var r =eval('('+obj_ajax.httpRequest.responseText+')');// eval();
		switch(r.status)
		{
			case 1:
				result = true;
				break;
			case 0:
				FB.ensureInit(function(){
					FB.Connect.showPermissionDialog(m,callback);
				});
				break;
			case -1:				
				fb_login(callback);
				break;
		}
	});
	obj_ajax.sendData();	
	return result;
}
function fb_init()
{	
	if(typeof(FB)=="undefined")
	{
		$.getScript("http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php",function(){fb_init()})
		return;	
	}
	if(!FB.Connect)
	{
		var fbInfo = null;
		var obj_ajax = new Ajax( '/account.php?act=fb_get_info', null, function(){
			fbInfo =eval('('+obj_ajax.httpRequest.responseText+')');
		});
		obj_ajax.sendData();
	
		FB.init(fbInfo.api_key,'/account.php?act=fb_login_callback');	
	}
}
function fb_login_link()
{
	fb_login(function(){location.href='/account.php?act=show_to_facebook_wall';});
}
function fb_login(callback)
{
	fb_init();
	if((typeof(FB)=="undefined") || !FB.Connect)
	{
		setTimeout(function(){fb_login(callback)},2000);
		return ;
	}
	
	FB.ensureInit(function(){
		FB.Connect.ifUserConnected(function(){//fbconnect
			 FB.Facebook.get_sessionState().waitUntilReady(function(session) {
				if(session && session.uid)
					{//get login result	
						var r = null;
						var str_parameters = "uid="+session.uid;
						var obj_ajax = new Ajax( '/account.php?act=fb_login_result', str_parameters, function(){
							r =eval('('+obj_ajax.httpRequest.responseText+')');
						});
						obj_ajax.sendData();
						if(r.status=='1')// login successfully
						{
							if(callback)
								callback();
							else
								location.reload();						
						}
						else if(r.status=='0')//
							location.href="/account.php?act=fb_account_notLinked";	
						else if(r.status=='-1')// session is not login
						{
							FB.Connect.forceSessionRefresh();
							FB.Connect.requireSession();
						}
						else
						{					
							$$('loginErrorBox').innerHTML = r.msg;
							$$('loginErrorBox').style.display = 'block';	
						}
					}
					else
						FB.Connect.requireSession();
			});
		},//User is Connected
		function(){//fbnotconnect
			FB.Connect.requireSession();			
		});
	});
	
}

function ajaxLogin( obj_form ){
		var isLogin = true; 
		if( obj_form ){
			if( !obj_form.email.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
				alert( 'Please enter a valid email address for your username.' );
				obj_form.email.focus();
				return false;
			}
			if( obj_form.password.value.length < 6 ){
				alert( 'Please enter your password.' );
				obj_form.password.focus();
				return false;
			}
			var str_parameters = 'email=' + obj_form.email.value + '&password=' + obj_form.password.value + 
					'&keep_login='+$$('chk_keep_login').checked;
			$$('login_button').disabled = true;
		}else{
			var str_parameters = 'logout=';
			isLogin = false;
		}
		var obj_ajax = new Ajax( '/_loginform.php', str_parameters, function(){
			if( obj_ajax.httpRequest.responseText ){
				alert(obj_ajax.httpRequest.responseText);
				$$('login_button').disabled = false;
			}else{
				if(location.href.indexOf('mystuff.php')>-1)
					location.href="/";
				else if(isLogin)
					location.href="/mystuff.php";
				else
					window.location.reload();
			}
		});
		obj_ajax.sendData();
		return false;
}
function tagFavorite(fid,type)
{
	var str_parameters = "fid="+fid+"&type="+type;
	var obj_ajax = new Ajax( '/account.php?act=tag_favorite', str_parameters, function(){
		var result =eval('('+obj_ajax.httpRequest.responseText+')');// eval();
		alert(result.msg);
		//if(result.status==0)
		//	showLogin();
	});
	obj_ajax.sendData();	
}
var _document_loaded = false;
function doPrint() 
{
	var bodyHTML=window.document.body.innerHTML;    
	var sprnstr="<!--startprint-->";    
	var eprnstr="<!--endprint-->";    
	var prnhtml=bodyHTML.substr(bodyHTML.indexOf(sprnstr)+17);    
	var prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));    
	window.document.body.innerHTML="<div align='left'><img src='/images/logo_print.gif'>"+prnhtml+"</div>";    
	window.print(); 
	if(navigator.userAgent.toLowerCase().indexOf('firefox') >= 0)
		setTimeout(function(){window.document.body.innerHTML=bodyHTML; }, 8000); 
	else
		window.document.body.innerHTML=bodyHTML;
}
/********************************************************************************************/
function check_email(mail)
{
	return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
}
/********************************************************************************************/
function check_ip(ip){
	var reg=/^(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))(\.(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))){3}$/
	if(reg.test(ip)){
		return true;
	}else{
		return false;
	}
}
/********************************************************************************************/
function sele_value(obj_seleName)
{
	return obj_seleName.options[obj_seleName.selectedIndex].value;
}
// set the object "select" 's options be selected by value or text 
function sele_Index(obj_seleName,seleValue)
{
	for(var i=0;i<obj_seleName.options.length;i++)
	{
		if(obj_seleName.options[i].value==seleValue||obj_seleName.options[i].text==seleValue)
		{
			obj_seleName.options[i].selected=true;			
			return true;
		}
	}
	return false;
}
function sele_Exist(objSelect,objItemValue)
{
     var isExist = false;
     for(var i=0;i<objSelect.options.length;i++)
     {
         if(objSelect.options[i].value == objItemValue)
         {
             isExist = true;
             break;
         }
     }      
     return isExist;
} 
function sele_Add(objSelect,objItemText,objItemValue)
{
     if(sele_Exist(objSelect,objItemValue))
		return false;
     else
     {
		 var n = objSelect.options.length;
         var varItem = new Option(objItemText,objItemValue);
		 try{
		 objSelect.options.add(varItem);
		 }catch(e)
		 {
			var oOption = document.createElement("OPTION");
			oOption.value=objItemValue;
			oOption.innerHTML=objItemText;
			objSelect.appendChild(oOption);
		 }			
         return true;
     }    
}
function sele_Remove(objSelect,objItemValue)
{
     if(sele_Exist(objSelect,objItemValue))
     {
         for(var i=0;i<objSelect.options.length;i++)
         {
             if(objSelect.options[i].value == objItemValue)
             {
                 objSelect.remove(i);
                 break;
             }
         }        
         return true;            
     }
     else
		return false;

}
function sele_Clear(objSelect)
{
     objSelect.options.length = 0

}
function chbSelectAll(o,name)
{
	var cbs = document.getElementsByName(name);
	for(var i=0; i<cbs.length;i++)
		cbs[i].checked = o.checked;
}
/********************************************************************************************/
function $( void_obj ){
	if( void_obj.tagName )
		return void_obj;
	try{
		return $$( void_obj );
	}catch( error_e ){
		return alertError( error_e );
	}
};
function $N( str_tagName ){
	return document.getElementsByTagName( str_tagName );
}
function $CE( str_string , str_cssText ){
	var obj_object = document.createElement( str_string );
	if( str_cssText && obj_object ){
		try{
			obj_object.style.cssText = str_cssText;
		}catch( error_e ){}
	}
	return obj_object;
}
addEventHandler = function( obj_target , str_eventType , fun_handler ){
	if( obj_target.addEventListener )
		obj_target.addEventListener( str_eventType , fun_handler , false );
	else if( obj_target.attachEvent )
		obj_target.attachEvent( 'on' + str_eventType , fun_handler );
	else
		obj_target['on' + str_eventType] = null;
}
removeEventHandler = function( obj_target , str_eventType , fun_handler ){
	if( obj_target.removeEventListener )
		obj_target.removeEventListener( str_eventType , fun_handler , false );
	else if( obj_target.detachEvent )
		obj_target.detachEvent( 'on' + str_eventType , fun_handler );
	else
		obj_target['on' + str_eventType] = null;
}
function sortTable( str_objID , int_cellNumber , bool_isNumber ){
	this.str_oddTrStyleClassName = 'trOdd';
	this.str_evenTrStyleClassName = 'trEven';
	this.obj_object = $( str_objID );
	if( this.obj_object.tagName.toLowerCase() != 'table' ){
		alert( 'Type of require object not extends table.' );
		return false;
	}
	this.sortString = function( arr_para1 , arr_para2 ){
		if( arr_para1.void_value > arr_para2.void_value )
			return 1;
		else if( arr_para1.void_value < arr_para2.void_value )
			return -1;
		return 0;
	};
	this.sortStringDesc = function( arr_para1 , arr_para2 ){
		if( arr_para1.void_value > arr_para2.void_value )
			return -1;
		else if( arr_para1.void_value < arr_para2.void_value )
			return 1;
		return 0;
	};
	this.sortNumber = function( arr_para1 , arr_para2 ){
		return arr_para1.void_value - arr_para2.void_value;
	};
	this.sortNumberDesc = function( arr_para1 , arr_para2 ){
		return arr_para2.void_value - arr_para1.void_value;
	};

	this.obj_head = obj_object.tHead;
	this.obj_body = obj_object.tBodies[0];
	this.obj_foot = obj_object.tFoot;
	this.obj_trArray = this.obj_body.rows;

	if( this.obj_trArray[0].sortSet )
		this.sortSet = '';
	else
		this.sortSet = 'desc';

	this.arr_temp = new Array();
	for( var int_i = 0 ; int_i < obj_trArray.length ; int_i ++ ){
		this.arr_temp[int_i] = new Array();
		this.arr_temp[int_i]['int_index'] = int_i;
		this.arr_temp[int_i]['void_value'] = obj_trArray[int_i].cells[int_cellNumber].innerHTML;
		this.arr_temp[int_i]['obj_tr'] = obj_trArray[int_i];
		this.arr_temp[int_i]['obj_tr'].sortSet = this.sortSet;
	}
	if( this.sortSet ){
		if( bool_isNumber )
			this.arr_temp.sort( this.sortNumberDesc );
		else
			this.arr_temp.sort( this.sortStringDesc );
	}else{
		if( bool_isNumber )
			this.arr_temp.sort( this.sortNumber );
		else
			this.arr_temp.sort( this.sortString );
	}
	this.obj_documentFragment = document.createDocumentFragment();
	this.obj_newBody = $CE( 'tbody' );
	for( var int_i = 0 ; int_i < this.arr_temp.length ; int_i ++ ){
		if( int_i % 2 )
			this.arr_temp[int_i]['obj_tr'].className = this.str_oddTrStyleClassName;
		else
			this.arr_temp[int_i]['obj_tr'].className = this.str_evenTrStyleClassName;
		this.obj_newBody.appendChild( this.arr_temp[int_i]['obj_tr'] );
	}
	this.obj_documentFragment.appendChild( this.obj_newBody );
	this.obj_object.removeChild( this.obj_body );
	if( this.obj_foot )
		this.obj_object.insertBefore( this.obj_documentFragment , this.obj_foot );
	else
		this.obj_object.appendChild( this.obj_documentFragment );
}
function onedition( obj_div , obj_textarea , bool_edition ){
	if( !bool_edition ){
		obj_div.style.display = '';
		obj_textarea.style.display = 'none';
	}else{
		obj_textarea.style.height = obj_div.offsetHeight + 'px';
		obj_div.style.display = 'none';
		obj_textarea.style.display = '';
		obj_textarea.focus();
	}
}
function nolinebreaks( str_id , bool_editTextarea , obj_other ){
	$(str_id).value = $(str_id).value.replace( /\r?\n/g , ' ' );
	if( bool_editTextarea && $(str_id).style.display == 'none' ){
		if( !obj_other )
			onedition( $(str_id).nextSibling , $(str_id) , true );
		else
			onedition( obj_other , $(str_id) , true );
	}
}
function tryThese() {
	var returnValue;
	for (var int_i = 0, length = arguments.length; int_i < length; int_i++) {
		var fun_lambda = arguments[int_i];
		try {
			returnValue = fun_lambda();
			break;
		} catch (e) {}
	}
	return returnValue;
}
function getElementSpace( obj_element ){
	var arr_return = new Object();
	arr_return.left=arr_return.top=0;
	var obj_temp = obj_element;
	while( obj_temp.tagName.toLowerCase() != "body" ) {
		arr_return.left += obj_temp.offsetLeft;
		arr_return.top += obj_temp.offsetTop;
		obj_temp = obj_temp.offsetParent;
	}
	arr_return.bTop = arr_return.top + obj_element.offsetHeight;
	arr_return.bLeft = arr_return.left + obj_element.offsetWidth;
	return arr_return; 
}
/**
 * AJAX封装
 */
function AJAX( str_src , str_parameters , str_formID , bool_rewrite ){
	var obj_ajax = this;
	this.getHttpRequest = function(){
		return tryThese(
		  function() {return new ActiveXObject('Microsoft.XMLHTTP')},
		  function() {return new XMLHttpRequest()},
		  function() {return new ActiveXObject('Msxml2.XMLHTTP')}
		) || false;
	}
	this.httpRequest = null;
	this.contentType = 'application/x-www-form-urlencoded';
	this.src = str_src;
	this.parameters = str_parameters;
	this.str_formID = str_formID;
	this.bool_rewrite = bool_rewrite ? 1 : 0;
	this.onready = function(){
		if( obj_ajax.bool_rewrite )
		{
			if(typeof(obj_ajax.str_formID) == "string")
				document.getElementById(obj_ajax.str_formID).innerHTML = obj_ajax.httpRequest.responseText;
			else
				obj_ajax.str_formID.innerHTML = obj_ajax.httpRequest.responseText;
		}
	}
	this.checkResponse = function(){
		try{
			if( obj_ajax.httpRequest.readyState == 4 ){
				if( obj_ajax.httpRequest.status && obj_ajax.httpRequest.status != 200 ){
					alert( obj_ajax.httpRequest.status );
					return false;
				}
				if( obj_ajax.checkXML ){
					if( !obj_ajax.checkXMLResponse() )
						return false;
				}
				obj_ajax.onready( obj_ajax.httpRequest );
			}
		}catch( err_e ){}
	}
	this.sendData = function(){
		this.httpRequest = this.getHttpRequest();
		this.httpRequest.open( 'POST' , this.src , true );
		this.httpRequest.setRequestHeader( 'Accept','text/javascript, text/html, application/xml, text/xml, */*' );
		this.httpRequest.setRequestHeader( "Content-Type" , this.contentType );
		this.httpRequest.onreadystatechange = this.checkResponse;
		this.httpRequest.send( this.parameters );
	}
}
function Ajax( str_src , str_parameters , fun_function ){
	var obj_ajax = this;
	this.getHttpRequest = function(){
		return tryThese(
		  function() {return new ActiveXObject('Microsoft.XMLHTTP')},
		  function() {return new XMLHttpRequest()},
		  function() {return new ActiveXObject('Msxml2.XMLHTTP')}
		) || false;
	}
	this.httpRequest = null;
	this.contentType = 'application/x-www-form-urlencoded';
	this.src = str_src;
	this.parameters = str_parameters;
	this.onready = fun_function;
	this.checkResponse = function(){
		try{
			if( obj_ajax.httpRequest.readyState == 4 ){
				if( obj_ajax.httpRequest.status && obj_ajax.httpRequest.status != 200 ){
					alert( obj_ajax.httpRequest.status );
					return false;
				}
				if( obj_ajax.checkXML ){
					if( !obj_ajax.checkXMLResponse() )
						return false;
				}
				obj_ajax.onready( obj_ajax.httpRequest );
			}
		}catch( err_e ){}
	}
	this.sendData = function(){
		this.httpRequest = this.getHttpRequest();
		this.httpRequest.open( 'POST' , this.src , false );
		this.httpRequest.setRequestHeader( "Content-Type" , this.contentType );
		this.httpRequest.send( this.parameters );
		this.checkResponse();
	}
}
//copy of Submissons/index.php
function validateEmail(email){
	var emailRegEx = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return email.match(emailRegEx);
}

function checkSpaceInPassword(password){
	var passwordRegEx = /\s/;
	return password.match(passwordRegEx);
}

function validateNumberString(str_number){
	var numberRegEx = /^[0-9]+$/;
	return str_number.match(numberRegEx);
}

function validateNumberStringExtends(str_number){
	var numberRegEx = /^[0-9][0-9]*([ ,-][0-9]+)*$/;
	return str_number.match(numberRegEx);
}


function goToTop(){
	document.location.href = "#top";
}


function verifyEmpty(name){
	name = name.trim();
	if ( name.length < 1 || name.match( /^[ ]+$/ ) )
		return false;
	return true;

}

function getFieldError( obj_elements ){
	var str_comments = obj_elements.parentNode.parentNode.cells[0].innerHTML;
	alert( 'The data for the ' + str_comments.substring( 0, str_comments.length - 2 ) + ' field is missing or invalid.' );
	obj_elements.focus();
	return false;
}

function onlynum(e,isint)
{
	if ( !e )
	   e = event ;	
	var iCode = ( e.keyCode || e.charCode ) ;	
	if(typeof(isint)!='undefined')
		return (
			( iCode >= 48 && iCode <= 57 )   // Numbers
			//|| (iCode >= 37 && iCode <= 40)   // Arrows
			|| iCode == 8       // Backspace
		) ;
	else
		return (
			( iCode >= 48 && iCode <= 57 )   // Numbers
			//|| (iCode >= 37 && iCode <= 40)   // Arrows
			|| iCode == 8       // Backspace
			//|| iCode == 45       // -
			|| iCode == 46       // Delete
		) ;
}
//get the queryString value of the thisURL 
function Request(QueryString,strHref)
{
	if(strHref==null)
		strHref=window.location.href;
	var strParm="";
	if(strHref.search(/\?/)!=-1)
	{
		strHref=strHref.substr(strHref.search(/\?/)+1);
		strHref=strHref.split(/&/);
		for(var icount = 0; icount<strHref.length; icount++)
		{
			if(strHref[icount].search("^"+QueryString+"=")!=-1)
			{
				strParm=strHref[icount].substr(QueryString.length+1)
			}
		}
		return(strParm);
	}
	else
		return 0;
} 

//set the QueryString's new value of the URL 
// this function need function Request(QueryString)
function SetQuery(keys,values,url)
{
	if(url==null)
		url =location.href;
	var pos = url.indexOf("#");
	var _anchor = "";
	if(pos>-1)
	{
		_anchor = url.substring(pos,url.length);
		url = url.substring(0,pos);
	}
	if(keys.constructor ==Array)
	{
		for(var i=0;i<keys.length;i++)
		{
			if(!Request(keys[i],url))
			{
				if(url.indexOf("?")<1)
					url+="?"+keys[i]+"="+values[i];
				else   
				{
					url = url.replace('&'+keys[i]+"=",'');
					url+="&"+keys[i]+"="+values[i];
				}
			}
			else
				url=url.replace(keys[i]+"="+Request(keys[i],url),keys[i]+"="+values[i]);
		}
	}
	else
	{		
		if(!Request(keys,url))
		{
			if(url.indexOf("?")<1)
				url+="?"+keys+"="+values;
			else   
			{
				url = url.replace('&'+keys+"=",'');
				url+="&"+keys+"="+values;
			}
		}
		else
			url=url.replace(keys+"="+Request(keys,url),keys+"="+values);
	}
	return url+_anchor;
}
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function addScript(src) 
{
	var scriptElement;
	
	// Check if we have the script loaded already
	var scriptElements = document.getElementsByTagName('script');
	if (scriptElements ) {
	var c = scriptElements.length;
	for (var i = 0; i < c; i++) {
	  scriptElement = scriptElements[i];
	  if (scriptElement.src == src) {
		// Found a match
		return;
	  }
	}
	}
	
	
	scriptElement = document.createElement("script");
	scriptElement.type = "text/javascript";
	scriptElement.src = src;
	var parent = document.getElementsByTagName('HEAD')[0] || document.body;
	parent.appendChild(scriptElement);
	return scriptElement;
}