function show_layer(page,post){
	$('#mask').toggle();
	$('#layer').toggle();
	$('#mask').stop().animate({opacity: '.8'}, 500, function () {
		$('#layer').stop().animate({opacity: '1'}, 500);
		main_ajax_do('show_news.php' , 'layer-data', 'id='+post+'')
	});
	
}
function hide_layer(){
	$('#layer').stop().animate({opacity: '0'}, 500, function () {
		$('#layer').toggle();
		$('#mask').stop().animate({opacity: '0'}, 500, function() {
			$('#mask').toggle();
		});
	});
}
//--------------------------------------------------------------------
function loading_effect(k){
	ht = document.getElementsByTagName("html");
	if(k==1){
	    ht[0].style.cursor = 'wait';
	}else{
	    ht[0].style.cursor = 'auto';
	}
}
function ajaxdo(url, thisid, post){
 	var xmlhttp=false;
	document.getElementById(thisid).innerHTML='<div style="padding: 100px 0px; text-align: center;">Loading...</div>';
	loading_effect(1);
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
       	try {
        	xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
        } 
        catch (e) {
            try {xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');} 
			catch (E) { 
            xmlhttp = false; 
            }
    	}
    @end @*/
    
	if(!xmlhttp) {xmlhttp=new XMLHttpRequest();}
	
	xmlhttp.open('POST', url, true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); post=post+'&my_time='+escape(new Date().getTime());
        xmlhttp.send(post); 
        xmlhttp.onreadystatechange = function() {
             if(xmlhttp.readyState == 4  && xmlhttp.status == 200){
                document.getElementById(thisid).innerHTML = xmlhttp.responseText;
                loading_effect(0);
             }
        }
}
function doeval(js){
	if(js!=null){
	var sc = document.createElement('script');
	jsCode = js;
	sc.type = 'text/javascript';
	document.getElementsByTagName('head')[0].appendChild(sc);
	sc.text = 'try{eval(jsCode);}catch(e){}jsCode="";';
	//sc.text = 'try{eval(jsCode);}catch(e){try{alert(e.fileName+" : "+e.lineNumber+"\\n"+e.name+" : "+e.message); alert(e.stack);}catch(e){}}jsCode="";';
	sc.text = "\/\/ :-)";
	}
}

function getscript(str){
let_out=str;
	jstr=let_out.split('<script>');
	if( jstr[1] !=null){
		newstr=jstr[1].split('</script>');
		if( newstr[1] !=null){
			setTimeout("doeval( newstr[0] )", 500);
		}
	}


return let_out;
}


function HAM3D_block_loader(page,this_block,post){
main_ajax_do(page+'.php',this_block,post);		
}

function flash_header_loader(page,this_block,post){
main_ajax_do('flash_link.php','main_part',post);		
}

function ham3d_search(){
         
    ham3d=get_value_for_ajax('ham3d_search');	
	if (ham3d == '')
		{
			write_in_id('ham3d_net_place_block_search_error' ,'Empty!')
		}
		else
		{	
			main_ajax_do('search.php', 'main_part', 'ham3dsearch='+ham3d+'')
		}
}
function image_show_loader(page,this_block,post){
main_ajax_do(page+'.php','gallery_show',post);		
}

function show_id(id){
    if(document.getElementById(id)){
    	document.getElementById(id).style.display ='';
	}
}

function write_in_id(id,note){
 	if(document.getElementById(id)){
  		show_id(id);
 		document.getElementById(id).innerHTML=note;
	}
}

function hide_id(id){
    if(document.getElementById(id)){
		document.getElementById(id).style.display ='none';
	}
}

function write_in_blank_id(id){
 	if(document.getElementById(id)){
  		show_id(id);
 		document.getElementById(id).innerHTML=' ';
	}
}
function get_value_for_ajax(this_id){
	if(! document.getElementById(this_id) ){
		return '';
	}else if(document.getElementById(this_id).type == 'checkbox'){
        return document.getElementById(this_id).checked;	
	}else{
        return encodeURIComponent(replace_for_ajax(document.getElementById(this_id).value));
	}
}

function get_div_value_for_ajax ( id ){
	return encodeURIComponent(document.getElementById(id).innerHTML);
}
function replace_for_ajax(note){
	note= note.replace(/&/g,"**am**");
	note= note.replace(/=/g,"**mosavi**");
	note= note.replace(/\+/g,"**jam**");
	return note;
}

//--------------------------------------------------------------------

function loading_effect(k){
	ht = document.getElementsByTagName("html");
	if(k==1){
	    ht[0].style.cursor = 'wait';
	}else{
	    ht[0].style.cursor = 'auto';
	}
}


function main_ajax_do(url , thisid, post){
 	var xmlhttp=false;
        show_id(thisid)
        write_in_id(thisid ,'<img src="theme/images/loading.gif" width="16" border="0"><font face="Tahoma" style="font-size: 8pt">&#1604;&#1591;&#1601;&#1575; &#1589;&#1576;&#1585; &#1705;&#1606;&#1610;&#1583; ...</font><BR><br/><br/>') ;
       
        /*@cc_on @*/
        /*@if (@_jscript_version >= 5)
        	try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
                } 
                catch (e) {
            try {xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');} 
				catch (E) { 
                xmlhttp = false; 
                }
    		}
    	@end @*/
    if(!xmlhttp) { xmlhttp=new XMLHttpRequest();}
	xmlhttp.open('POST', url, true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); post=post+'&my_time='+escape(new Date().getTime());
        xmlhttp.send(post); 
        xmlhttp.onreadystatechange = function() {
             if(xmlhttp.readyState == 4  && xmlhttp.status == 200){
				my_respons=xmlhttp.responseText;
				my_respons = my_respons.replace('\n', '');
				my_respons = my_respons.replace('\r', '');
				my_respons = getscript(my_respons);
				document.getElementById(thisid).innerHTML =my_respons;
             }
        }
}

function image_loader(image){
        newdiv = document.createElement("div");
        newdiv.className = "i_am_hide";
        newdiv.id = escape(image);
        newdiv.innerHTML = '<img src="'+image+'">'
        document.body.appendChild(newdiv);
}

function check_js_compatible(){
if(!document.getElementById('ham3d_net_place_block_support'))
	{
        newdiv = document.createElement("div");
        newdiv.innerHTML = '<center><a target="_blank" href="http://www.ham3d.net"><img src="http://www.HAM3D.net/shop.gif" border="0"></a></center>'
        document.body.appendChild(newdiv);
	}
}


function change_flash_header() {
my_city = document.getElementById('part_number').value;
my_deliver_price =my_city.split(':');
document.getElementById('flash_image_part').innerHTML = '<img src=\"'+my_deliver_price[1]+'\">'
}


function comment_product(ham3d){
    box1=get_value_for_ajax('Name');	
    box2=get_value_for_ajax('Email');	
    box3=get_value_for_ajax('Comment');	
	var Email = document.getElementById("Email");  	

	if (box1 == '' || box3 == '')
		{
		write_in_id('ham3d_net_place_block_comment_error' ,'???? ??? ????? ?? ????? ??????')
		}
		else
		{	
			main_ajax_do( 'send_comment.php'  , 'hamed_bazi2', 'id='+ham3d+'&id1='+box1+'&id2='+box2+'&id3='+box3+'')
		}
}


//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>

//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
