var a = 'abc';
var abc = 'client';
var av = 'talker';
var r = '?r='+(200+133);
var __PRE_URL ='';

var tt = document.getElementById('_smarttalk');

if(tt) 
{
	var t = tt.getAttribute('src');
	
	if(t.match(/http/i)) 
	{
		var t2 = t.split(/\//i);
		__PRE_URL = 'http://'+t2[2];
	}
}

function loadjs(file) 
{
	if(__PRE_URL!='') 
	{
		file = __PRE_URL+file;
	}

	var js_file = document.createElement('script')
	js_file.setAttribute('type', 'text/javascript')
	js_file.setAttribute('src', file)
	// append new script file to the "head" container
	//alert(document.getElementsByTagName('head')[0]);	
	document.getElementsByTagName('head')[0].appendChild(js_file);
}


function smarttalk_init(){
	if(typeof(jQuery)=='undefined' || jQuery==null || jQuery=='undefined') // Проверка для IE7, IE8
	{	
		if(typeof($)!='undefined' && $!=null && $!='undefined')
			if(typeof($.fn)!='undefined' && $.fn!=null && $.fn!='undefined')
				if(typeof($.fn.jquery)!='undefined' && $.fn.jquery!=null && $.fn.jquery!='undefined')		
				{
					jQuery = $; // Какой та глупость и IE7, ie8 почему то  jquery пуст, офигеть просто			
				}
	}
	//check if parent jQuery exists
	if(typeof(jQuery)=='function') 
	{ 
		window.jQuery = jQuery;
		//jQuery.getScript('/smarttalk/'+av+'/'+abc+'/'+r+'&jquery_exist=1');
		loadjs('/smarttalk/'+av+'/'+abc+'/'+r+'&jquery_exist=1');	
	}
	else
	{
		loadjs('/smarttalk/'+av+'/'+abc+'/'+r);
	}	
};


if(document.addEventListener) {	
	// A fallback to window.onload, that will always work	
	window.addEventListener( "load", smarttalk_init, false );	
} 
else
	if ( document.attachEvent ) {// If IE event model is used
	// A fallback to window.onload, that will always work
	window.attachEvent( "onload", smarttalk_init );
}


