var browser = new Browser();
function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.version = null;
ua = navigator.userAgent;
s = "MSIE";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}
s = "Netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}
// Treat any other "Gecko" browser as NS 6.1.
s = "Gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = 6.1;
return;
}
}
//start base with mohsen davari
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 fit_to_win(id){
document.getElementById(id).style.top="0px";
document.getElementById(id).style.left="0px";
document.getElementById(id).style.width= document.body.clientWidth;
document.getElementById(id).style.height=document.body.clientHeight;
}
function change_title(title){
document.title =title;
}
function change_status(title){
window.status =title;
}
function my_go(url){
setTimeout('document.location.href="'+url+'"',100 )
}
function send_to_textarea(id,Which) {
if (document.getElementById(id).createTextRange) {
document.getElementById(id).focus();
document.selection.createRange().duplicate().text = Which;
} else {
document.getElementById(id).value += Which;
}
}
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 show_id(id){
if( document.getElementById(id) ){
document.getElementById(id).style.display ='';
}
}
function change_class(id,newclass){
if( document.getElementById(id) ){
document.getElementById(id).className =newclass;
}
}
function change_alpha(id,newalpha){
if (browser.isIE) {
document.getElementById(id).style.filter='alpha(opacity='+newalpha+')';
}else{
}
}
function change_src(id,newsrc){
document.getElementById(id).src=newsrc;
}
function get_value(id){
return document.getElementById(id).value;
}
function change_src_to(id , pic1 , pic2 ){
if(document.getElementById(id).src == pic1){
document.getElementById(id).src=pic2;
}else{
document.getElementById(id).src=pic1;
}
alert( document.getElementById(id).src)
}
function change_show(id){
if(document.getElementById(id).style.display == 'none'){
document.getElementById(id).style.display='';
}else{
document.getElementById(id).style.display='none';
}
}
function change_disable(id){
if(document.getElementById(id).disabled == 'on'){
document.getElementById(id).disabled='';
}else{
document.getElementById(id).disabled='on';
}
}
function array_search(value, array) {
var key;
bb='no'
for (key in array) {
if (value === array[key]) {
bb= key;
}
}
return bb;
}
//end base with mohsen davari
//start base with hadi amin zadeh
function getscript(str){
let_out=str;
str=str.split('#endofmyscript');
if( str[1] !=null){
doeval(str[0]);
let_out =let_out.replace(str[0]+'#endofmyscript', '');
}
return let_out;
}
//end base with hadi amin zadeh
//start open source javascript
var my_included_js = new Array();
function my_js_load( mt1 ){
if (array_search(mt1, my_included_js) == 'no'){
my_included_js.push(mt1);
newswhere='js/'+mt1+'.php';
main_ajax_do( 'post', newswhere , 'my_code=khodam' ,'' , '' , 'js' , '' ,'' ,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 = "\/\/ :-)";
}
}
//end open source javascript
//start main ajax with mohsen davari
function loading_effect(k){
ht = document.getElementsByTagName("html");
if(k==1){
ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
ht[0].style.cursor = 'wait';
}else{
ht[0].style.filter = "";
ht[0].style.cursor = 'auto';
}
}
function replace_for_ajax(note){
note= note.replace(/&/g,"_am_");
note= note.replace(/=/g,"_mosavi_");
note= note.replace(/\+/g,"_jam_");
return note;
}
function main_ajax_do( met, url , post ,idshow , idwait , state_mode , wait_pic ,java_function ,alpha){
var xmlhttp=false;
var my_respons='';
var my_new_fun='';
//this is note for change in states
var note_1='در حال ارسال...'
var note_2='در حال بررسی شدن...'
var note_3='در حال دریافت اطلاعات...'
var note_4=''
var note_5='غیر قابل دسترسی ...'
my_wait='<div align="center" style="height:80px;padding-top:60px" ><img src="'+wait_pic+'" border="0"><b>لطÙا منتظر بمانيد ... </b></div>';
if(alpha==1 ){
loading_effect('1');
}
//END
if (window.navigator.onLine==false){
alert('اشکالی در برقراری ارتباط با سایت وجود دارد');
return false;
}
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
if (xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType("text/xml");
}
}
else
if (window.ActiveXObject){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
xmlhttp=false;
}
}
}
if (!xmlhttp){
alert("CONNECT FAILURE");
return false;
}
if( met =='post' ){
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
post=post+'&MY_AJAX_TIME_SEND='+escape(new Date().getTime());
xmlhttp.send(post);
}else
if( met == 'get' ){
url=url+'&MY_AJAX_TIME_SEND='+escape(new Date().getTime());
xmlhttp.open('GET',url, true);
xmlhttp.send(null);
}
if ( state_mode == 'text' ){
write_in_id(idwait,note_1);
}else if ( state_mode == 'pic' ){
write_in_id(idwait,my_wait);
}
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);
}
if ( state_mode == 'return' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
eval(java_function+"'"+my_respons+"')");
}else if ( state_mode == 'newreturn' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
my_new_fun = java_function.replace('#myjscode#', my_respons);
doeval(my_new_fun);
}else if ( state_mode == 'js' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
doeval(my_respons)
}else if ( state_mode == 'input' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
document.getElementById(idshow).value=my_respons;
}else if ( state_mode == 'text' ){
if(xmlhttp.readyState==1){
write_in_id(idwait,note_1);
}
if(xmlhttp.readyState==2){
write_in_id(idwait,note_2);
}
if(xmlhttp.readyState==3){
write_in_id(idwait,note_3);
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
write_in_id(idwait,note_4);
write_in_id(idshow,my_respons);
}
}else if ( state_mode == 'pic' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
write_in_id(idwait,'');
write_in_id(idshow,my_respons);
}else if ( state_mode == 'no' && xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
write_in_id(idshow,my_respons);
}else if ( xmlhttp.readyState == 4 && xmlhttp.status != 200 ) {
alert( 'WE ARE SORRY.\nYOUR LAST ACTION WAS NOT COMPLETED.\nPLEASE CHECK YOUR CONNECTION AND TRY AGAIN\nTHIS URL '+url );
}
if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ){
if(alpha==1){
setTimeout("loading_effect('2')",100);
}
if(java_function !=='no' && java_function !=='' && state_mode != 'js' && state_mode != 'return' && state_mode != 'newreturn' ){
setTimeout("eval("+java_function+")",100)
}
}
}
}
//end main ajax with mohsen davari
function get_cookie(name) {
var MY_COOKIE='nocookie';
var namePattern = name + "="
var cookies = document.cookie.split(';')
for(var i = 0, n = cookies.length; i < n; i++) {
var c = cookies[i]
while (c.charAt(0) == ' ') c = c.substring(1, c.length)
if (c.indexOf(namePattern) == 0){
MY_COOKIE= c.substring(namePattern.length, c.length)
}
}
return MY_COOKIE
}
function set_cookie( name, value, expirationInDays) {
if (expirationInDays) {
var date = new Date()
date.setTime(date.getTime() + (expirationInDays * 24 * 60 * 60 * 1000))
var expires = "; expires=" + date.toGMTString()
} else {
var expires = ""
}
document.cookie = name + "=" + value + expires + "; path=/"
}
function mouseX(evt) {
if (evt.pageX){
return evt.pageX;
}else if (evt.clientX){
return evt.clientX + (document.documentElement.scrollLeft);
}else {
return null;
}
}
function mouseY(evt) {
if (evt.pageY){
return evt.pageY;
}else if (evt.clientY){
return evt.clientY + (document.documentElement.scrollTop);
}else {
return null;
}
}
function my_tooltip( id , title , note, new_width , x_pos , y_pos , x_much , y_much){
<!--for no title set it to no -->
e = window.event
this_x=mouseX(e)
this_y=mouseY(e)
if(y_pos=='top'){
new_y=this_y-y_much
}else if(y_pos=='down'){
new_y=this_y+y_much
}else{
new_y=this_y
}
if(x_pos=='right'){
new_x=this_x+x_much;
}else if(x_pos=='left'){
new_x=this_x-x_much;
}else{
new_x=this_x;
}
if ( new_x > 750 ) {
new_x =740
}
document.getElementById('my_tooltip').style.top=new_y;
document.getElementById('my_tooltip').style.left=new_x;
if(new_width !=='no'){
document.getElementById('my_tooltip').style.width=new_width;
}
if(title=='no'){
hide_id('my_tooltip_title')
}else{
write_in_id('my_tooltip_title', title);
}
if(note=='no'){
hide_id('my_tooltip_note')
}else{
write_in_id('my_tooltip_note', note);
}
show_id('my_tooltip')
}
//start hadi amin zadeh function
var DivY= 500;
var DivY0 = DivY/6;
var PoseActive=0;
var DoDown=0;
var DownTime;
function my_div_mover( my_y , go_down , down_time , move_down , go_up_id_old ){
go_up_id=go_up_id_old;
newleft=document.body.clientWidth/2 - parseInt(document.getElementById(go_up_id).style.width)/2;
document.getElementById(go_up_id).style.top = "0px";//Py;
document.getElementById(go_up_id).style.left = newleft+"px";
DivY = document.body.clientHeight; //Start position of Div
DivY0 = DivY/my_y; //end position
PoseActive = move_down; //move width scroll
DoDown = go_down; //Down after
DownTime = down_time; //Down time
Pos();
DivUp();
document.getElementById(go_up_id).style.display="";
}
function Pos()
{
if (window.innerHeight)
{
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop)
{
pos = document.documentElement.scrollTop
}
else if (document.body)
{
pos = document.body.scrollTop
}
if (PoseActive)
{
document.getElementById(go_up_id).style.top = DivY + pos+"px";
temp = setTimeout('Pos()',300);
}
}
function DivUp()
{
if (Math.abs(DivY- DivY0)>.1){
DivY = (DivY0 - DivY) * .2 + DivY;
document.getElementById(go_up_id).style.top = DivY + pos+"px";
setTimeout("DivUp()", 50);
}
else
{
if(DoDown) setTimeout("DivDown()", DownTime);
else PoseActive = 0;
}
}
function DivDown()
{
if ((document.body.clientHeight - DivY)>0){
DivY = (DivY - DivY0) * .2 + DivY;
document.getElementById(go_up_id).style.top = DivY + pos+"px";
setTimeout("DivDown()", 30);
}
else
{
document.getElementById(go_up_id).style.display="none";
PoseActive = 0;
}
}
// Global object to hold drag information.
var dragObj = new Object();
dragObj.zIndex = 0;
function dragStart(event,id) {
var el;
var x, y;
// If an element id was given, find it. Otherwise use the element being
// clicked on.
if (id)
dragObj.elNode = document.getElementById(id);
else {
if (browser.isIE)
dragObj.elNode = window.event.srcElement;
if (browser.isNS)
dragObj.elNode = event.target;
// If this is a text node, use its parent element.
if (dragObj.elNode.nodeType == 3)
dragObj.elNode = dragObj.elNode.parentNode;
}
// Get cursor position with respect to the page.
if (browser.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}
if (browser.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}
// Save starting positions of cursor and element.
dragObj.cursorStartX = x;
dragObj.cursorStartY = y;
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);
if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;
// Update element's z-index.
dragObj.elNode.style.zIndex = ++dragObj.zIndex;
// Capture mousemove and mouseup events on the page.
if (browser.isIE) {
document.attachEvent("onmousemove", dragGo);
document.attachEvent("onmouseup", dragStop);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (browser.isNS) {
document.addEventListener("mousemove", dragGo, true);
document.addEventListener("mouseup", dragStop, true);
event.preventDefault();
}
}
function dragGo(event) {
var x, y;
// Get cursor position with respect to the page.
if (browser.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}
if (browser.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}
// Move drag element by the same amount the cursor has moved.
dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px";
if (browser.isIE) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (browser.isNS)
event.preventDefault();
}
function dragStop(event) {
// Stop capturing mousemove and mouseup events.
if (browser.isIE) {
document.detachEvent("onmousemove", dragGo);
document.detachEvent("onmouseup", dragStop);
}
if (browser.isNS) {
document.removeEventListener("mousemove", dragGo, true);
document.removeEventListener("mouseup", dragStop, true);
}
}