function in_array( str_object, arr_object ) {
	var int_result = -1;
	var I;

	for( I=0; I < arr_object.length; I++ ){
		if ( arr_object[I] == str_object ) {
			int_result = I;
			continue;
		}
	}
	return int_result; 
}

// Assimilar a url da pagina
str_page                 = window.location.href;

var arr_url              = str_page.split( '?' );

var str_page1            = arr_url[0];

// Montagem padrao dos parametros da requisicao
str_qy                   = "&jscode=1";
str_qy                  += "&cd="    + encodeURIComponent( str_code );
str_qy                  += "&sh="    + encodeURIComponent( str_show );
str_qy                  += "&uk="    + encodeURIComponent( int_userKey );
str_qy                  += "&sn="    + encodeURIComponent( str_page1 );
str_qy                  += "&limit=" + encodeURIComponent( int_linksPerPage );
str_qy                  += "&nw="    + encodeURIComponent( boo_openInNewWindow );

var arr_namesReserved    = new Array( 'jscode', 'cd', 'sh', 'uk', 'sn', 'limit', 'nw' );

// Caso a url contenha variaveis a reenviar, assimilar todos os valores
if ( str_page.indexOf('?') != -1 ) {
	var str_queryEnv       = '&' + str_page.substr( str_page.indexOf( '?' ) + 1 );
	var boo_execIncValue   = false;
	var boo_execIncName    = false;
	var str_indexName      = '';
	var str_indexValue     = '';
	var arr_names          = new Array();
	var arr_values         = new Array();
	
	for ( var I = 0; I < str_queryEnv.length; I++ ) {
		if ( str_queryEnv.charAt( I ) == '&' ) {
			boo_execIncName    = true;
			boo_execIncValue   = false;
			
			if ( str_indexName != '' ) {
				arr_names.push( str_indexName );
				arr_values.push( str_indexValue );
			}
			
			str_indexName      = '';
			str_indexValue     = '';
		}
		
		if ( str_queryEnv.charAt( I ) == '=' ) {
			boo_execIncName    = false;
			boo_execIncValue   = true;
		}
		
		if ( boo_execIncValue )
			if ( str_queryEnv.charAt( I ) != '=' )
				if ( str_indexName != '' )
					str_indexValue = str_indexValue + str_queryEnv.charAt( I );
		
		if ( boo_execIncName )
			if ( str_queryEnv.charAt( I ) != '&' )
				str_indexName    = str_indexName + str_queryEnv.charAt( I );
	}
	
	if ( str_indexName != '' ) {
		arr_names.push( str_indexName );
		arr_values.push( str_indexValue );
	}
	
	// Acrescentar a variaveis aos parametros de envio
	var arr_keys           = new Array();
	var arr_keysNames      = new Array();
	var arr_keysValues     = new Array();
	var int_indexName      = -1;

	for ( var I = 0; I < arr_names.length; I++ ) {

		int_indexName        = in_array( arr_names[I], arr_keys );
		if ( in_array( arr_names[I], arr_namesReserved ) == -1 ) {
			if ( int_indexName == -1 ) {

				arr_keysNames.push( arr_names[I] );
				arr_keysValues.push( encodeURIComponent( arr_values[I] ) );
				arr_keys.push( arr_names[I] );

			} else {

				arr_keysNames[int_indexName]  =  arr_names[I];
				arr_keysValues[int_indexName] =  encodeURIComponent( arr_values[I] );
			}
		}
	}

	for ( var I = 0; I < arr_keysNames.length; I++ ) {
		str_qy               = str_qy + '&' + arr_keysNames[I] +'='+ arr_keysValues[I];
	}
}

// Montar div para exposicao dos links
document.writeln( '<div id="div_trocalinks" name="div_trocalinks" ></div>' );

// Enviar requisicao para o php
var head           = document.getElementsByTagName('head')[0];
var scriptElement  = document.createElement('script');
scriptElement.type = 'text/javascript';
scriptElement.src  = 'http://www.trocarlinks.com.br/scripts/?' + str_qy;
//scriptElement.src  = 'http://trocarlinks.desenv.com/scripts/?' + str_qy;

head.appendChild( scriptElement );