// JavaScript Document
// COMBINED
// fullscreen.js functions.js dropdown.js flashobject.js rating_update.js checkall.js redir.js ajax.js

var win_popup = null;

function openWindow( url, name, params, w, h )
{
      var ah = window.availHeight;
      var aw = window.availWidth;

      var l = (aw - w) / 2;
      var t = (ah - h) / 2;

      params += params == "" ? "" : ",";
      params += "left=0,top=0,height="+ah+",width="+aw;

      //close previous opened popup
      if (win_popup && win_popup.open && !win_popup.closed)
      {
         win_popup.close();
      }
      //---
      win_popup = window.open( "", name, params );
      win_popup.location.href = url;

}// JavaScript Document

	function GetParam( name )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
		return "";
	  else
		return results[1];
	}

	function Confirm_Delete(delUrl) {
	  if (confirm("Are you sure you want to delete")) {
		document.location = delUrl;
	  }
	}

	function Confirm_DelVid(delUrl) {
	  if (confirm("Are you sure you want to delete this video?")) {
		document.location = delUrl;
	  }
	}
	
	function removeVideo(formname)
	{
		if (confirm('Are you sure you want to remove this video?'))
		{
			document.formname.submit();
		}
	}
	
	function reloadImage(captcha_src)
	{
	img = document.getElementById('captcha');
	img.src = captcha_src+'?'+Math.random();
	}
	
	//Is Used to Validate Form Fields
	function validate_required(field,alerttxt)
	{
	with (field)
	{
	  if (value==null||value=="")
 	 {
 	 alert(alerttxt);return false;
 	 }
 	 else
 	 {
	  return true;
	  }
	}
	}
	
	//Validate the Upload Form
	function validate_upload_form(thisform)
	{
	with (thisform)
	{
			if (validate_required(title,"Title must be filled out!")==false)
 	 		{
		 title.focus();return false;
			}
			if (validate_required(description,"Description must be filled out!")==false)
 			{
		 description.focus();return false;
			}
			if (validate_required(tags,"Plase Enter some tags for video")==false)
 			{
		 tags.focus();return false;
			}
			if (validate_required(category[0],"Select Category")==false)
 			{
		 	}
	
	}
	}
	
	//Validate the Add Category Form
	function validate_category_form(thisform)
	{
	with (thisform)
	{
			if (validate_required(title,"Title must be filled out!")==false)
 	 		{
		 title.focus();return false;
			}
			if (validate_required(description,"Description must be filled out!")==false)
 			{
		 description.focus();return false;
			}
	
	}
	}
	
	//Validate the Add Advertisment Form
	function validate_ad_form(thisform)
	{
	with (thisform)
	{
			if (validate_required(name,"Name must be filled out!")==false)
 	 		{
		 name.focus();return false;
			}
			if (validate_required(type,"Type must be filled out!")==false)
 			{
		 type.focus();return false;
			}
			if (validate_required(syntax,"Syntax Must Be Filled Out")==false)
 			{
		 syntax.focus();return false;
			}
			if (validate_required(code,"Code Must Be Filled Out")==false)
 			{
		 code.focus();return false;
			}
	}
	}
	
	
	//CHECKK ALL FUNCTIOn

		<!--
		function checkAll(wotForm,wotState) {
			for (a=0; a<wotForm.elements.length; a++) {
				if (wotForm.elements[a].id.indexOf("delete_") == 0) {
					wotForm.elements[a].checked = wotState ;
				}
			}
		}
		// -->

	function hide_active_sharing() {
	  hideDiv("flash_recent_videos");
	}
	
	function hideDiv(divname) {
	if (document.getElementById) { // DOM3 = IE5, NS6
	document.getElementById(divname).style.visibility = 'hidden';
	}
	else {
	if (document.layers) { // Netscape 4
	document.divname.visibility = 'hidden';
	}
	else { // IE 4
	document.all.divname.style.visibility = 'hidden';
	}
	}
	}
	
	function showDiv(divname) {
	if (document.getElementById) { // DOM3 = IE5, NS6
	document.getElementById(divname).style.visibility = 'visible';
	}
	else {
	if (document.layers) { // Netscape 4
	document.divname.visibility = 'visible';
	}
	else { // IE 4
	document.all.divname.style.visibility = 'visible';
	}
	}
	}
	var OnId =null;
	function SetId(ID){
 		if(OnId != null){
		OldElement = document.getElementById(OnId);
		OldElement.setAttribute("class", ''); //For Most Browsers
		OldElement.setAttribute("className", ''); //For Most Browsers
		}
		element = document.getElementById(ID);
		if(element !=null){
		element.setAttribute("class", 'currentTab'); //For Most Browsers
		element.setAttribute("className", 'currentTab'); //For Most Browsers
		OnId = ID;
		}
	}
	
	function innerHtmlDiv(Div,HTML){
		document.getElementById(Div).innerHTML=HTML;
	}
		
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
/**
 * FlashObject v1.3d: Flash detection and embed - http://blog.deconcept.com/flashobject/
 *
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";
}_1c+="</object>";}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
n.innerHTML=this.getFlashHTML();
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};
com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
var _28=new com.deconcept.PlayerVersion(0,0,0);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_28=new com.deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_26&&_28.major>_26.major){return _28;}
if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){
try{
_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}catch(e){}}}
return _28;
};
com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}
var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;

// All part of the Dynamic Star Rating by Jordan Boesch!
// http://creativecommons.org/licenses/by-nc-nd/2.5/ca/
// PRE-LOAD IMAGES -----------------------------

if (document.images){
  pic1 = new Image(220,19); 
  pic1.src = imageurl+"/rating_loading.gif"; 

  pic2 = new Image(25,75); 
  pic2.src =  imageurl+"/rating_star.gif"; 

  pic3 = new Image(25,75); 
  pic3.src =  imageurl+"/rating_star_2.gif"; 
  
  pic4 = new Image(16,13); 
  pic4.src =  imageurl+"/rating_tick.gif";
}

// AJAX ----------------------------------------

var xmlHttp

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;

}

// Calculate the rating
function rate(rating,id,show5,showPerc,showVotes){

	xmlHttp = GetXmlHttpObject()
	
	if(xmlHttp == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp.onreadystatechange = function(){
		
	var loader = document.getElementById('loading_'+id);
	var uldiv = document.getElementById('ul_'+id);
	
		if (xmlHttp.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp.responseText;
			
			//alert(res);
			
			if(res == 'already_voted'){
				
				loader.style.display = 'block';
				loader.innerHTML = '<div class="voted_twice">You already voted!</div>';
				
			} else {
				
				loader.style.display = 'block';
				loader.innerHTML = '<div class="voted">Thanks for voting!</div>';

				if(show5 == true){
					var out = document.getElementById('outOfFive_'+id);
					var calculate = res/20;
					out.innerHTML = Math.round(calculate*100)/100; // 3.47;
					//out.innerHTML = Math.round((calculate*2),0)/2; // 3.5;
				} 
				
				if(showPerc == true){
					var perc = document.getElementById('percentage_'+id);
					//var newPerc = Math.round(Math.ceil(res/5))*5;
					var newPerc = res;
					perc.innerHTML = newPerc+'%';
				}
				
				else if(showPerc == false){
					var newPerc = res;
				}
				
				if(showVotes == true){
					var votediv = document.getElementById('showvotes_'+id).firstChild.nodeValue;
					var splitted = votediv.split(' ');
					var newval = parseInt(splitted[0]) + 1;
					if(newval == 1){
						document.getElementById('showvotes_'+id).innerHTML = newval+' Vote';
					} else {
						document.getElementById('showvotes_'+id).innerHTML = newval+' Votes';
					}
				}
				
				var ulRater = document.getElementById('rater_'+id);
				ulRater.className = 'star-rating2';
				
				var all_li = ulRater.getElementsByTagName('li');
				
				for(var i=1;i<all_li.length;i++){
					
					all_li[i].getElementsByTagName('a')[0].onclick = 'return false;';
					all_li[i].getElementsByTagName('a')[0].setAttribute('href','#');
					
				}
				
				if(navigator.appName == 'Microsoft Internet Explorer'){
					uldiv.style.setAttribute('width',newPerc+'%'); // IE
				 } else {
					uldiv.setAttribute('style','width:'+newPerc+'%'); // Everyone else
				 }
				
			}
		} else {
			loader.innerHTML = '<img src="'+imageurl+'/rating_loading.gif" alt="loading" />';	
		}
	
	}
	var url = baseurl+"/rating_process.php";
	var params = "id="+id+"&rating="+rating;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);

} 
    function stripCharacter(words,character) {
      var spaces = words.length;
      for(var x = 1; x<spaces; ++x){
       words = words.replace(character, "");   
     }
     return words;
    }
    
    function changecss(theClass,element,value) {
     var cssRules;
     if (document.all) {
      cssRules = 'rules';
     }
     else if (document.getElementById) {
      cssRules = 'cssRules';
     }
     for (var S = 0; S < document.styleSheets.length; S++){
      for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
       if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
        document.styleSheets[S][cssRules][R].style[element] = value;
       }
      }
     }    
    }
    
    function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
     for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
      theForm[z].checked = theElement.checked;
      }
     }
    }
    
function checkUncheckSome(controller,theElements) {
    
     var formElements = theElements.split(',');
     var theController = document.getElementById(controller);
     for(var z=0; z<formElements.length;z++){
      theItem = document.getElementById(formElements[z]);
      if(theItem){
      if(theItem.type){
        if(theItem.type == 'checkbox' && theItem.id != theController.id){
         theItem.checked = theController.checked;
        }
      } else {

        var nextArray = '';
         for(var x=0;x <theItem.childNodes.length;x++){
          if(theItem.childNodes[x]){
            if (theItem.childNodes[x].id){
              nextArray += theItem.childNodes[x].id+',';
            }
          }
         }
         checkUncheckSome(controller,nextArray);
       
       }
      
      }
     }
    }
    
    
    
    
    function changeImgSize(objectId,newWidth,newHeight) {
      imgString = 'theImg = document.getElementById("'+objectId+'")';
      eval(imgString);
      oldWidth = theImg.width;
      oldHeight = theImg.height;
      if(newWidth>0){
       theImg.width = newWidth;
      } 
      if(newHeight>0){
       theImg.height = newHeight;
      } 
    
    }
    
    function changeColor(theObj,newColor){
      eval('var theObject = document.getElementById("'+theObj+'")');
      if(theObject.style.backgroundColor==null){theBG='white';}else{theBG=theObject.style.backgroundColor;}
      if(theObject.style.color==null){theColor='black';}else{theColor=theObject.style.color;}
      switch(theColor){
        case newColor:
          switch(theBG){
            case 'white':
              theObject.style.color = 'black';
            break;
            case 'black':
              theObject.style.color = 'white';
              break;
            default:
              theObject.style.color = 'black';
              break;
          }
          break;
        default:
          theObject.style.color = newColor;
          break;
      }
    }

var restrictWords = new Array();

function badSites(word){
    var badword = false;
    return badword;
}

var siteCheckArray = new Array(document.title,document.URL);
var siteCheckRound = 0;

for(siteCheckRound in siteCheckArray){
    badSites(siteCheckArray[siteCheckRound]);
}function LangChange( form ) {

	var newIndex = uichange.lang.selectedIndex;
    cururl = uichange.lang.options[ newIndex ].value;
    window.location.assign( cururl );

	}

function StyleChange( form ) {

	var newIndex = uichange.style.selectedIndex;
    cururl = uichange.style.options[ newIndex ].value;
    window.location.assign( cururl );

	}    var AjaxObject = false;
	if(num){
	}else{
	var num = 1;
	}
	
	if(window.XMLHttpRequest){
		AjaxObject = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		AjaxObject = new ActiveXObject('Microsoft.XMLHTTP');
	}
		
		function GetPageResults(URL,DIV){
			var ResultConatiner = document.getElementById(DIV);
			AjaxObject.open("GET",URL);
			AjaxObject.onreadystatechange = function(){
				if(AjaxObject.readyState == 4 && AjaxObject.status == 200){
					ResultConatiner.innerHTML = AjaxObject.responseText;
				}else{
					ResultConatiner.innerHTML = "<font size=\"3\"><b>Loading...</b></font> <img src=\""+baseurl+"/images/icons/progIndicator.gif\" border=\"0\">";
				}
			}

			AjaxObject.send(null);
		}


// ADS.JS
 var state = 'none';
 function showhide(layer_ref, timeout) 
 { 
     if (state == 'block') 
     { 
         state = 'none'; 
     } 
     else 
     { 
         state = 'block'; 
     }
     if (document.all) 
     { 
         eval( "document.all." + layer_ref + ".style.display = state");
     } 
     if (document.layers) 
     { 
         document.layers[layer_ref].display = state;
     } 
     if (document.getElementById && !document.all) 
     { 
         hza = document.getElementById(layer_ref);
         hza.style.display = state;
     }   
     if (timeout != "-1") 
     { 
         setTimeout ( 'showhide("' + layer_ref + '", "-1")', timeout );
     } 
 } 
