var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
function allClicked(checked) {
  var l = document.Videos.elements.length;
  for (i = 0; i < l; i++) {
    var e = document.Videos.elements[i];

    if (e.name == "video_id" ) {
	  e.checked = checked;
    } 
  }
}
function deClicked(a) {

  var l = document.Videos.elements.length;
  for (i = 0; i < l; i++) {
    var e = document.Videos.elements[i];

    if (e.name == "video_id") {
	  e.checked = false;
    }
  }
  if (a == 1) {
	  document.Videos.debox2.checked = document.Videos.debox1.checked;
  }
  else {
	  document.Videos.debox1.checked = document.Videos.debox2.checked;
  }
  if(document.Videos.debox1.checked){
	  document.Videos.allbox1.checked = false;
	  document.Videos.allbox2.checked = false;
  }
}
function checkIt(a) {
  var l = document.Videos.elements.length;
  for (i = 0; i < l; i++) {
    var e = document.Videos.elements[i];

    if (e.name == "video_id" && e.value == a) {
      e.checked = true;
    }
  }
}

function submit_form()
{
  document.Rate_A_Zorpian.submit();
}
//--- add country state city---
function select_change_country()
{
        document.Rate_A_Zorpian.state.value = "0";
        document.Rate_A_Zorpian.city.value = "0";
    document.Rate_A_Zorpian.submit();
}

function select_change_state()
{
    document.Rate_A_Zorpian.city.value = "0";
    document.Rate_A_Zorpian.submit();
}

function fixPNG(myImage) {    
	var arVersion = navigator.appVersion.split("MSIE");     
	var version = parseFloat(arVersion[1]);     
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";        
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";         
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";         
		var imgStyle = "display:inline-block;" + myImage.style.cssText;         
		var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";         
		myImage.outerHTML = strNewHTML;     
	} 
}  

function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}

function check_create_collection_form(myform) {
	if(myform.title.value == '') {
		$('title_error').innerHTML = ZORPIA_JS_LANG.COLLECTION.NO_TITLE;
		return false;
	} else {
		$('title_error').innerHTML = '';
	}

	if(!myform.non_adult.checked) {
		$('agreement_error').innerHTML = ZORPIA_JS_LANG.COLLECTION.NO_AGREEMENT;
		return false;
	} else {
		$('agreement_error').innerHTML = '';
	}

	if(myform.category.value < 1) {
		$('category_error').innerHTML = ZORPIA_JS_LANG.COLLECTION.NO_CATEGORY;
		return false;
	} else {
		$('category_error').innerHTML = '';
	}
	myform.submit2.disabled = true;
	return true;
}

function ClipBoard(inElement) {

  if (window.clipboardData) {
        window.clipboardData.setData("Text",inElement.value);
    } else {
      var flashcopier = 'flashcopier';
      if(!document.getElementById(flashcopier)) {
        var divholder = document.createElement('div');
        divholder.id = flashcopier;
        document.body.appendChild(divholder);
      }
      
      var so = new SWFObject('http://static.zorpia.com/flash/_clipboard.swf', 'copy_contents', '0', '0', '4');
      so.addVariable('clipboard', encodeURIComponent(inElement.value));
      so.write('flashcopier');
  }
  
    inElement.focus();
    inElement.select();

    return false;
}

function set_action (action) {
    if(any_checked()){
	    document.Videos.action.value = action;
	    document.Videos.submit();
    }
}

function swap_videos(action,dir,video_id) {
	document.Videos.action.value = action;
	document.Videos.swap_dir.value = dir;
	document.Videos.swap_video.value = video_id;
	document.Videos.submit();
}

function check_edit_video_form(form) {
    var name = $("title");
    var Terms = $("agreement");
    
	var err_title = $('err_title');
    if(name !=null && name.value == 0)  {
        err_title.innerHTML = "<div class='error'><li>" + ZORPIA_JS_LANG.VIDEO.NO_TITLE + "</li></div>";
        return false;
    } else {
        err_title.innerHTML = "";
    }

    var err_agreement = $('err_agreement');
    if(!Terms.checked)
    {
        err_agreement.innerHTML  = "<div class='error'><li>" + ZORPIA_JS_LANG.VIDEO.NO_AGREEMENT + "</li></div>";
        return false;
    } else {
        err_agreement.innerHTML = '';
    }
    $('btnBubmit').disabled = true;
}

