// JavaScript Document

//////////DETECT BRowser//////////////////



var BrowserDetect = {

	init: function () {

		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";

		this.version = this.searchVersion(navigator.userAgent)

			|| this.searchVersion(navigator.appVersion)

			|| "an unknown version";

		this.OS = this.searchString(this.dataOS) || "an unknown OS";

	},

	searchString: function (data) {

		for (var i=0;i<data.length;i++)	{

			var dataString = data[i].string;

			var dataProp = data[i].prop;

			this.versionSearchString = data[i].versionSearch || data[i].identity;

			if (dataString) {

				if (dataString.indexOf(data[i].subString) != -1)

					return data[i].identity;

			}

			else if (dataProp)

				return data[i].identity;

		}

	},

	searchVersion: function (dataString) {

		var index = dataString.indexOf(this.versionSearchString);

		if (index == -1) return;

		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));

	},

	dataBrowser: [

		{

			string: navigator.userAgent,

			subString: "Chrome",

			identity: "Chrome"

		},

		{ 	string: navigator.userAgent,

			subString: "OmniWeb",

			versionSearch: "OmniWeb/",

			identity: "OmniWeb"

		},

		{

			string: navigator.vendor,

			subString: "Apple",

			identity: "Safari",

			versionSearch: "Version"

		},

		{

			prop: window.opera,

			identity: "Opera"

		},

		{

			string: navigator.vendor,

			subString: "iCab",

			identity: "iCab"

		},

		{

			string: navigator.vendor,

			subString: "KDE",

			identity: "Konqueror"

		},

		{

			string: navigator.userAgent,

			subString: "Firefox",

			identity: "Firefox"

		},

		{

			string: navigator.vendor,

			subString: "Camino",

			identity: "Camino"

		},

		{		// for newer Netscapes (6+)

			string: navigator.userAgent,

			subString: "Netscape",

			identity: "Netscape"

		},

		{

			string: navigator.userAgent,

			subString: "MSIE",

			identity: "Explorer",

			versionSearch: "MSIE"

		},

		{

			string: navigator.userAgent,

			subString: "Gecko",

			identity: "Mozilla",

			versionSearch: "rv"

		},

		{ 		// for older Netscapes (4-)

			string: navigator.userAgent,

			subString: "Mozilla",

			identity: "Netscape",

			versionSearch: "Mozilla"

		}

	],

	dataOS : [

		{

			string: navigator.platform,

			subString: "Win",

			identity: "Windows"

		},

		{

			string: navigator.platform,

			subString: "Mac",

			identity: "Mac"

		},

		{

			   string: navigator.userAgent,

			   subString: "iPhone",

			   identity: "iPhone/iPod"

	    },

		{

			string: navigator.platform,

			subString: "Linux",

			identity: "Linux"

		}

	]



};

BrowserDetect.init();



////////////////////////////////////////////////////////////////



//////////////////////////



var FadeDurationMS=1000;

function SetOpacity(object,opacityPct)

{

	// IE.

	object.style.filter = 'alpha(opacity=' +opacityPct+ ')';

	// Old mozilla and firefox

	object.style.MozOpacity = opacityPct/100;

	// Everything else.

	object.style.opacity = opacityPct/100;

}

function ChangeOpacity(id,msDuration,msStart,fromO,toO)

{

	var element=document.getElementById(id);

	var msNow = (new Date()).getTime();

	var opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;

	if (opacity>=100)

	{

		SetOpacity(element,100);

		element.timer = undefined;

	}

	else if (opacity<=0)

	{

		SetOpacity(element,0);

		element.timer = undefined;

	}

	else 

	{

		SetOpacity(element,opacity);

		element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",10);

	}

}

function FadeInImage(foregroundID)

{

	var foreground=document.getElementById(foregroundID);

	if (foreground.timer) window.clearTimeout(foreground.timer);



	var startMS = (new Date()).getTime();

			foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "'," + FadeDurationMS + "," + startMS + ",11,100)",10);

		

}

/*

if(BrowserDetect.browser=="Firefox")  {  

animatedcollapse.addDiv('one', 'fade=1,speed=400,group=pets,height=55pt,hide=0')

animatedcollapse.addDiv('two', 'fade=1,speed=400,group=pets,height=55pt,hide=1')

animatedcollapse.addDiv('three', 'fade=1,speed=400,group=pets,height=55pt,hide=1')

animatedcollapse.addDiv('summery', 'fade=1,speed=400,height=55pt,hide=1')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted

	//$: Access to jQuery

	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID

	//state: "block" or "none", depending on state

}



}





else if (BrowserDetect.browser=="Explorer") {  

 

animatedcollapse.addDiv('one', 'fade=1,speed=400,group=pets,height=25%,hide=0')

animatedcollapse.addDiv('two', 'fade=1,speed=400,group=pets,height=25%,hide=1')

animatedcollapse.addDiv('three', 'fade=1,speed=400,group=pets,height=25%,hide=1')

animatedcollapse.addDiv('summery', 'fade=1,speed=400,height=55pt,hide=1')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted

	//$: Access to jQuery

	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID

	//state: "block" or "none", depending on state

}



}

animatedcollapse.init()



//////////////////

*/





//alert(''+x);



//////////////////////////////////////////////////////////////////////////////////

function createRequestObject(){



var req;



if(window.XMLHttpRequest){

//For Firefox, Safari, Opera

req = new XMLHttpRequest();

}

else if(window.ActiveXObject){

//For IE 5+

req = new ActiveXObject("Microsoft.XMLHTTP");

}

else{

//Error for an old browser

alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');

}



return req;

}



//Make the XMLHttpRequest Object





function sendRequest(method, url,content){

	

var http = createRequestObject();

if(method == 'get' || method == 'GET'){



http.onreadystatechange=function()

  {

  if (http.readyState==4 && http.status==200)

    {

    content.innerHTML=http.responseText;

    }

  }

http.open(method,url);

http.send(null);

}



}

//////////////////////////////////////////////////////////////////////////////////

function typeSummery(divid,newsid)

{

	

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {

	//alert();

  var element=document.getElementById(divid);

  

  element.innerHTML=xmlhttp.responseText;

 

 //changecontent(xmlhttp.responseText,divid)

              

           

    }

  }

xmlhttp.open("GET","typesummery.php?rd="+newsid,true);

xmlhttp.send();

}



//////////////////////////////////////////////////////////////////////////////////

function getLen(int,element2)

{

	

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {

	//alert();

	

  element2.innerHTML=xmlhttp.responseText;

	 

              

           

    }

  }

xmlhttp.open("GET","getlength.php?len="+int,true);

xmlhttp.send();

}



function getLenIE(int,element2)

{

	

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {

	//alert();	

  element2.innerHTML=xmlhttp.responseText;

	 

              

           

    }

  }

xmlhttp.open("GET","getlength2.php?len="+int,true);

xmlhttp.send();

}



//////////////////////////////////////////////////////////////////////////////////

function getMenuItem(int,element2)

{

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    

    {

		var place=document.getElementById(element2);

        place.innerHTML=xmlhttp.responseText;

    }

  }

xmlhttp.open("GET","getMenuItem.php?divd="+int,true);

xmlhttp.send();

}











/////////////////////////////////////////////////////////////////////////////////

function addRow(tableID) {



  var parent = document.getElementById(tableID);

  var rowCount = parent.childNodes.length;

            

			if(rowCount<=40){

		   

			getLen(rowCount,parent);

		

			}







          



        }

 

        function deleteRow(tableID) {

			 if(BrowserDetect.browser=="Firefox")  {  

            try {

		    var parent = document.getElementById(tableID);

            var rowCount2 = parent.childNodes.length;

            var temp= rowCount2-1;

          

                //var row = table.rows[i];

                //var chkbox = row.cells[0].childNodes[0];

                if(temp>10) {

				

			     // table.deleteRow(temp);

                  //  

                  //   table.deleteRow(temp);

                  //  temp--;

                for(t=6 ;t>0; t--){

				 parent.removeChild(parent.childNodes[temp]);	

				 temp--;

				}

				

            }

            }catch(e) {

                alert(e);

            }

			

			

			 }

			 

			 else if (BrowserDetect.browser=="Explorer") {  



try {

	

	        var parent = document.getElementById(tableID);

            var rowCount2 = parent.childNodes.length;

            var temp= rowCount2-1;

	

           

          

                //var row = table.rows[i];

                //var chkbox = row.cells[0].childNodes[0];

                if(temp>10) {

			     for(t=6 ;t>0; t--){

				 parent.removeChild(parent.childNodes[temp]);	

				 temp--;

				}

                

				

            }

            }catch(e) {

                alert(e);

            }



}



        }

 //////////////////////////////////////////////////////////////////////////////////







function showpopmenu(divid,elmnt){

var pop = document.getElementById(elmnt);

getMenuItem(divid,elmnt);

pop.style.display='block';	

}



function showpop2(divid){

var pop = document.getElementById(divid);	

pop.style.display='block';	

}

function hidepop(tdId){

var pop = document.getElementById(tdId);	

pop.style.display='none';	

}

 //////////////////////////////////////////////////////////////////////////////////

function gool(){

txt=document.getElementById('serch').value;

window.open('sgoogle'+txt+'.html');





}







////////////////////////////////////Footer/////////////////////////////////////////////





//////////////////////

function showUser(){

 xmlHttp=GetXmlHttpObject();

 if (xmlHttp==null) {

  alert ("Browser does not support HTTP Request");

   return;

    }

	var namevalue=encodeURIComponent(document.getElementById('user').value);

    var mailvalue=encodeURIComponent(document.getElementById('maillist').value);



	var url="mailList.php";

	url=url+"?user="+namevalue+"&mail="+mailvalue+"&sid="+Math.random();

	xmlHttp.onreadystatechange=stateChanged;

	//xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=windows-1256");

	xmlHttp.open("POST",url,true);

	

	xmlHttp.send(null);}

/////////////////////////



function GetXmlHttpObject(){

var xmlHttp=null;try { // Firefox, Opera 8.0+, Safari

 xmlHttp=new XMLHttpRequest(); }

 catch (e) { //Internet Explorer

  try  {  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  }

   catch (e)  {  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

     } }

   return xmlHttp;}

   ///////////////////////

   

    function stateChanged() {

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

	  //document.getElementById('statusdiv').innerHTML="";

	  document.getElementById("error_messege").innerHTML=xmlHttp.responseText; 

	   }

	   else    {

	  

	   document.getElementById('error_messege').innerHTML="<div align=\'center\'  ><img src='images\\progress_circle.gif'> Loading ...</div>";    } }





////////////////////////

function check_email(e) {

ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";



for(i=0; i < e.length ;i++){

if(ok.indexOf(e.charAt(i))<0){ 

return (false);

}	

} 



if (document.images) {

re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;

re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

if (!e.match(re) && e.match(re_two)) {

return (-1);		

} 



}



}   

////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////
