/******************************************************
OpenWindow Function
Input Parameters:
	******************
	REQUIRE PARAMETERS
	******************
	sFileName : 	file name (string)
	wwidth : 		width of the window (int)
	wheight : 		height of the window (int)
	******************
	OPTIONAL PARAMETERS
	******************
	winname: 	    name of the window (string) 
							Default value : "defaultwindowname"
	scrollbars:		  open window whith scrollbar (yes,no) 
							Default value : "yes"
	top:		  		top coordinates of the window ()
						  	Default value :  Center of the screen
						  	Another Integer Value:		Absolute position
	
******************************************************/
var Common={
	SystemDebugger:0,
	Texts:{

	},
	Viewer:'',
	GetViewer:function(){
		if(this.Viewer==''){
			this.Viewer=popupObj.Clone();
		}
		return this.Viewer;
	},
	Clone:function(object){
		var new_object={};
		for (a in object){new_object[a]=object[a];}
		return new_object;
	},
	Extend:function(obj){
		obj.update=function(content){
			obj.innerHTML=content;
		}
		obj.show=function(){
			obj.style.display='';
		}
		obj.hide=function(){
			obj.style.display='none';
		}
		obj.toggle=function(){
			if(obj.style.display=='none'){
				obj.show();
			} else {
				obj.hide();
			}
		}

	},
	InsertScriptFile:function(ParnetElement,ScriptSrc,sleep){
		document.WriteCursor=ParnetElement;
		var Script= document.createElement('script');
		Script.type= 'text/javascript';
		Script.src= ScriptSrc;
		ParnetElement.appendChild(Script);
		if(sleep) {
			this.Sleep(sleep);
		}
		
	},
  	Sleep:function(naptime){
		naptime = naptime * 1000;
		var sleeping = true;
		var now = new Date();
		var alarm;
		var startingMSeconds = now.getTime();
		while(sleeping){
			alarm = new Date();
			alarmMSeconds = alarm.getTime();
			if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
		}        
    },
	HideElements:function(objParams){
		if(objParams.Multiple){
			for(var a=objParams.Multiple.FirstIndex;a<=objParams.Multiple.LastIndex;a++){
				$(objParams.Multiple.Prefix+a).hide();
			}
		}
	},
 	ie6d:function(){
		return (navigator.appName=='Microsoft Internet Explorer' && (navigator.appVersion.indexOf('MSIE [7-9]')==-1));
	},
	HttpGet:function(arrParams,onSuccess){
		new Ajax.Request ("/ajax.interface.php",
		{
			method: "post",
			parameters: arrParams.join("&"),
			onSuccess: function (res) {
				onSuccess(res.responseText);
			}
		}
		);
	},
	Browser:{
		is_ff:function(){
			return (navigator.userAgent.indexOf('Firefox')!=-1);
		},

		is_ie:function(){
			return (navigator.userAgent.indexOf('MSIE')!=-1);
		},
		is_opera:function(){
			return (navigator.userAgent.indexOf('Opera')!=-1);
		},
		ie6d:function(){
			return (navigator.appName=='Microsoft Internet Explorer' && (navigator.appVersion.indexOf('MSIE 7.0')==-1));
		},
		ie7d:function(){
			if(navigator.appName=='Microsoft Internet Explorer'){
				var x=navigator.appVersion.match(/MSIE ([0-9]+)\./);
				if(x[1] && x[1]<8){
					return 1;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}
	},
	fnSetOpacity: function(Obj,opacity){
		if(typeof(Obj)=='string'){
			Obj=$(Obj);
		}
		if(this.Browser.is_ie()){
			Obj.style.filter="alpha(opacity="+(opacity*100)+")";
		}
		if(this.Browser.is_ff()){
			Obj.style.MozOpacity=opacity;
		}
		if(this.Browser.is_opera() || is_safari() || is_chrome()){
			Obj.style.opacity=opacity;
		}
	}
}



function OpenWin(sFileName,wwidth,wheight,winname,sScrollbars,iTop) {
        // open window
        //alert('ok');
		var topvalue = 0;
		
		if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5) 
			sScrollbars="yes";
		else 
			sScrollbars = "no";
		if(winname == "") 
			winname = "defaultwindowname";
		
		 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
		 if(iTop == "" || arguments.length < 6)   
		 	topvalue = yy;			
		 else
		 	topvalue = iTop;
         options ='resizable=yes, location=no, toolbar=no, status=no, left='+xx+', top='+topvalue+', menubar=no, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);		
        }	

function OpenWindow(sFileName,wwidth,wheight,winname,sScrollbars,iTop) {
        // open window
		var topvalue = 0;
		
		if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5) 
			sScrollbars="yes";
		else 
			sScrollbars = "no";
		if(winname == "") 
			winname = "defaultwindowname";
		
		 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
		 if(iTop == "" || arguments.length < 6)   
		 	topvalue = yy;			
		 else
		 	topvalue = iTop;
         options ='resizable=yes, location=no, toolbar=no, status=no, left='+xx+', top='+topvalue+', menubar=no, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);		
        }	
		
function sendsal(id_it,far)
{
var amm=eval("far.amount"+id_it+".value");   // alert(amm);
 
  location.href=="cart.php?ID_ITEMs="+id_it+"&ammount="+amm+"&adsal";
   
}

function display_subjects()
{
	if(document.search.search_word.value.length==0) 
	{alert ("");
	document.search.search_word.focus();
	return false;
	}
	else return true;
}

	var dom = document.getElementById
	var ns6=dom && !document.all
	var ns4=document.layers
	var ie4=document.all && !dom
	var opr=navigator.userAgent.indexOf("Opera")
	
	function Swap(target) 
	{ 
		if (dom) target = document.getElementById(target).style;  
		if (ns4) target = document.eval(target);
		if (ie4) target = eval(target).style;
		target.display = target.display == "none" ? "" : "none"
	}

function show_media(id)
		{
		window.open('/show.php?show=media&id='+id, 'mediaview','scrollbars=no,status=no,top=0,left=' + (screen.width/2-323) + ',outerwidth=3,width=400,outerheight=5,height=350');
		}	

function elemShowHide(el_id)
{
	if(el=document.getElementById(el_id))
	{
		el.style.display=el.style.display=="none"?"":"none"
	}
	return false;
}


function toUnixTime(iDay, iMonth, iYear) // Convert date to UNIX timestamp format
{
    var humDate = new Date(Date.UTC(iYear, iMonth-1, iDay,
          0, // HOur
          0, // Min
          0  // Sec
		  ));
    return (humDate.getTime()/1000.0);
}
	function Swap_Images(target,id) 
	{ 
		if (dom) target = document.getElementById(target).style;  
		if (ns4) target = document.eval(target);
		if (ie4) target = eval(target).style;
		target.display = target.display == "none" ? "" : "none";
		
		if(id!="")
		{
			if(target.display == "none") 
				document.getElementById(id).src="gfx/menu_side_plus.gif";
			else
			    document.getElementById(id).src="gfx/menu_side_minus.gif";
	    }
	}

