function FavoriteAction(action,div_name)
{
document.getElementById(div_name).style.display = '';
document.getElementById("txt_"+div_name).value='ssssssssssssssssssssssssss';
}

function FavoriteActionSave(action,div_name)
{
alert(document.getElementById("txt_"+div_name).value);
//loading Command
//sendCommand

}

function ShowHidePanelSettings(panelname) {
	if(document.getElementById(panelname).style.display == 'none')
         {
	document.getElementById(panelname).style.display = '';

         var dv_content='<div style="margin-bottom:5px;">Display: <select name="settingslist" class="combo2"><option>Thumb Only</option><option>Description only</option><option>Thumb with description</option></select></div><div style="margin-bottom:5px;">Rows &nbsp;&nbsp;: <select name="settingslist" class="combosmall"><option>1</option><option>2</option><option>3</option><option>4</option><option selected>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option></select></div><div style="margin-bottom:5px;">Sort by: <select name="settingslist" class="combo2"><option>File Name</option><option>Date Modified</option><option>File Type</option><option>Size</option><option>Most Viewed</option><option>Most Commented</option></select></div><input name="button" type="submit" class="btn" id="button" value="Submit" style="margin-left:52px; margin-top:5px;"  /><input name="button" type="submit" class="btn" id="button" value="Cancel" style="margin-top:5px;" onClick=JAVASCRIPT:ShowHidePanel(panelname)/>';

         document.getElementById(panelname).innerHTML=dv_content;
         }
	else
	document.getElementById(panelname).style.display = 'none';
}

function ShowHidePanel(panelname) {

	if(document.getElementById(panelname).style.display == 'none')
	document.getElementById(panelname).style.display = '';
	else
	document.getElementById(panelname).style.display = 'none';
}
function ShowPanel(panelname) {
	document.getElementById(panelname).style.display = '';
}
function HidePanel(panelname) {
	document.getElementById(panelname).style.display = 'none';
}

function show_confirm(msg, action)
{
        var cnfm=confirm(msg);
        if(cnfm==true)
        {
           alert("Action: " + action);
        }
}

function onTabClick()
{
	//alert("tab clicked...");
}

function refreshPageContent()
{
  alert("refresh content...");
}

function updateBlockPositions(block)
{
 //alert(block);
}

function thumbOverNew(thumb)
{
	fcode = thumb.split('_');
	var objaddedToCart = document.getElementById('addTC'+fcode[1]);
	var objaddedToFav = document.getElementById('addTF'+fcode[1]);
	var objaddedToQ = document.getElementById('addTQ'+fcode[1]);
	if(objaddedToCart.style.display != 'block' || objaddedToFav.style.display != 'block' || objaddedToQ.style.display != 'block')
	{document.getElementById(thumb).style.display='block';}
}
/* END : ADD TO OPTIONS + IMAGE */
function ShowingListMode()
{
     // fillType('1,2',  'inner');
	YAHOO.util.Dom.get('ul1_LBlock').style.display = 'none';
	YAHOO.util.Dom.get('ul1_RBlock').style.width = '475px';
      var searchTargetBlock;

                if(document.getElementById("home_div").style.display == "none")
                searchTargetBlock="li1_9";
                else
                {
                searchTargetBlock="li1_search";
document.getElementById("home_div").style.display = "none";
document.getElementById("inner_div").style.display = "block";
//fillType('1,2',  '');
customize('')
                }
		
	YAHOO.util.Dom.get("li1_9").style.display = 'block';
//getDvBlockSts();
}


function fillFavoriteList(favoriteList, elementName)
{
var elSel = document.getElementById(elementName);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
      elSel.remove(i);
  }
//alert('Favorite Length: '+favoriteList.length);
if (favoriteList)
for (var i=0; i < favoriteList.length; i++)
{

var optn = document.createElement("OPTION");
optn.text = favoriteList[i].name;
optn.value = favoriteList[i].id;
elSel.options.add(optn);

}

browseFavorite(elementName);
}


function browseFavorite(id){
//alert('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: ');
//alert(document.getElementById(id).value);

document.getElementById('MyFavourites_D').innerHTML='<div align="center"><img width="18px" height="18px" border="0" align="middle" src="images/imgloader.gif" ></div>';

	    mySWF.callSWF("browseFavorite", ["JS", document.getElementById(id).value, 5, 1]);   

}



function addToBlock(obj){
  
//   alert('dddd 1 '+ obj.total);


var dv_content="";

//alert("obj.Qtype: " + obj.Qtype);

if (obj.Qtype =='files'){

//alert("FilesLength: "+ obj.files.length);

for (var i=0; i<obj.files.length; i++)
{
if (!obj.files[i].title)
   obj.files[i].title='no title';
  // alert('add To block this Value: ' +obj.files[i].title);

   //alert(obj.files[i].title);
}
 
//alert("blockName1 ");
//alert("obj.files :" + obj.files );
//alert("obj.blockStyle :" + obj.blockStyle );
 dv_content=build_dvContent(obj.files, obj.blockStyle);
//alert("blockName2");

} 
else if (obj.Qtype == 'albums')
{

	var albums=obj.albums;
	for (var i=0; i<albums.length; i++)
         {
               var album_=albums[i];
               dv_content+='<a href="#!section=showalbum&albumid=' + album_.id + '" class="catmenu">'+album_.name+'</a><br/>';
	}
}

//alert('dddd 2 '+ obj.blockName);
//alert(dv_content);
//alert("blockName: "+ obj.blockName);

if(document.getElementById("home_div").style.display == "none")
dv_content+=writePages(obj.total, 3, obj.page, 'onClickEvents2,'+obj.actionName+','+obj.blockName);
dv_content+='<div id="'+obj.blockName+'_loader" style="display:none">Loading Content...</div>';

//alert(obj.blockName);
YAHOO.util.Dom.get(obj.blockName + '_D').innerHTML = dv_content;

}

function browseThis(blockName, pg)
{
alert(blockName + ' ' + pg);
}
function setRating(ratings,raters)
{
	if (ratings > 0){
		var rateingAverage=ratings/raters;
		rateingAverage=rateingAverage.toPrecision(3);
	}else{
		rateingAverage=0.00;
	}
	rating.init(rateingAverage.toString());
	document.getElementById("ratingdiv").title="المعدل: " + rateingAverage.toString();
}


function orginalImage(f){
document.getElementById("PopDiv").innerHTML='<div style="padding: 12px;"><div style="position: absolute; border: 1px solid #000;top: 2px; left: 2px;"><img width="9" height="9" border="0" src="images/cancel.png" onclick="Popup.hideAll();"></div><img src="http://www.yabdoo.com/gallery/watch.php?f='+f+'"  style="padding: 6px; border: 1px solid #000;" ></div>';
Popup.show('PopDiv','dvimage',"center center",{'constrainToScreen':true});return false;
}
function paraseTags(tags)
{
if (!tags)
return "";

var tagsArray=tags.split(',');
var TaggedTagList=new Array();
for (var i=0; i<tagsArray.length; i++)
{
var tagWord=tagsArray[i];
var tagLink="#!section=search&tag="+tagWord;
var tagTagged='<a href="'+tagLink+'">'+tagWord+'</a>';

TaggedTagList.push(tagTagged);

}
if (TaggedTagList)
var tagListString=TaggedTagList.join(', ')
return tagListString;
}
function alert3(test1,test2,test3)
{
alert(test1);

alert(test2);
alert(test3);
}

function fileType(id){
	var type = new Array("1","2","3");
	var tname = new Array("Image","Video","Other");
	for(var i=0;i<type.length;i++){
		if(id==type[i])
		return tname[i];
	}	
}



function fillFileInfo(file_)
{
//alert("fillFileInfo...");

//popup("popUpDiv");
hidePopup("popUpDiv");
YAHOO.util.Dom.get('likedislike_bar').innerHTML = '';

fileType(file_.fileType);

if (file_.fileType==2)
{
	//document.getElementById('player').style.display='block';
	//document.getElementById('dvimage').style.display='none';
	document.getElementById('caminfo').style.display='none';
         document.getElementById('rltd_video_td').innerHTML='تضمين المشاهد ذات علاقة';
         document.getElementById('play_hd_td').innerHTML='تشغيل لوضع HD';
         document.getElementById('play_hd').style.display='block';
         document.getElementById('imgSizes').style.display='none';
         document.getElementById('vid_embedDetails').style.display='block';

var shwType=document.getElementById('vidTyp').value;
var embdType;
if(document.getElementById('vidReal').checked==true)
embdType="";
else if(document.getElementById('vidThumb').checked==true)
embdType=document.getElementById('vidThumb').value;
    //document.getElementById('link_code').value="http://www.yabdoo.com/v/"+file_.code;
    document.getElementById('link_code').value="http://www.yabdoo.com/gallery/watch.php?f="+file_.code+"&showType="+shwType+"&showSize="+embdType;
}
else
{
	//document.getElementById('player').style.display='none';
         document.getElementById('rltd_video_td').innerHTML='Include related images';
         document.getElementById('play_hd_td').innerHTML='';
         document.getElementById('play_hd').style.display='none';
         document.getElementById('imgSizes').style.display='block';
         document.getElementById('vid_embedDetails').style.display='none';
var embdTyp;
if(document.getElementById('imgLarge').checked==true)
embdTyp=document.getElementById('imgLarge').value;
else if(document.getElementById('imgResized').checked==true)
embdTyp=document.getElementById('imgResized').value;
else if(document.getElementById('imgThumb').checked==true)
embdTyp=document.getElementById('imgThumb').value;

         //document.getElementById('link_code').value="http://www.yabdoo.com/v/"+file_.code+"&showSize="+embdTyp;
document.getElementById('link_code').value="http://www.yabdoo.com/gallery/watch.php?f="+file_.code+"&showSize="+embdTyp;

var imagecnts = '<img width="435" height="330" src="http://www.yabdoo.com/gallery/watch.php?showSize=resized&f='+file_.code+'"/>';
	//document.getElementById('dvimage').style.display='block';     
	
      if (file_.image)
      {
        /*
	if(file_.image.resizedSize)
         {

	imagecnts+='<div id="dv_bimage" align="right" style="width:20px;float:right;background-image:none;right:8px;top:-25px;position:relative;z-index: 3;"><span style="cursor: pointer;border:1px solid #000;"><img onclick=orginalImage("'+file_.code+'"); width="12" height="12" border="0" src="images/search_icon.png"></span></div>'

	}
        */

         if(file_.image.resizedSize)
         CameraEditedFunction(file_.image);
      }	

}

//document.getElementById('dvimage').innerHTML=imagecnts;

	document.getElementById('show_comments').innerHTML="";
	document.getElementById("pg_links").innerHTML ="";

	if (file_.comments==0)
	{
         //alert("NoComm: " + كن أول من يعلق على هذا الملف)
         document.getElementById('show_comments').innerHTML="No Comments";
         }
	for (var item in file_)
	{
		if ((file_[item]==null) && (file_[item]==undefined))
		file_[item]=" ";
	}
	document.getElementById('f').value=file_.code;
	document.getElementById("fileTitle").innerHTML=file_.title;
    setBrowserTitle();

var tags_parased=paraseTags(file_.tags);

var pattern=/\s/g;


file_.tags=file_.tags.replace(pattern, '&nbsp');

//file_.tags="";

	if (!file_.title)
	file_.title="No title";
	
         if (!file_.description)
	file_.description="";

//alert("title: " + file_.title);
//alert("description: " + file_.description);

var FileInfo_message='<table width="340px" style="direction:ltr;">'

+'<tr><td><img id="img_dvfiletitle" src="images/edit.png" width="10" height="10" border="0" style="cursor:pointer; display:none;" onClick=editFile("Title","dvfiletitle",""); /></td><td><div id="dvfiletitle" style="float:right;pading:1px;">'+file_.title+'</div></td></tr>'

+'<tr><td><img id="img_filedescription" src="images/edit.png" width="10" height="10" style="cursor:pointer; display:none;" onClick=editFile("Description","filedescription",""); /></td><td><div id="dvareatxt_filedescription" style="float:right;pading:1px;">&nbsp;:&nbsp;الوصف</div><span id="filedescription" style="float:right;">' +file_.description +'</span></td></tr><tr><td colspan="2">'

				  + file_.date + '&nbsp;:&nbsp;التاريخ</td></tr><tr><td colspan="2">'
				  + 'المشاهدات&nbsp;:&nbsp;' + file_.views +'</td></tr><tr><td colspan="2">'

                  + 'التعليقات&nbsp;:&nbsp;' + file_.comments +'</td></tr>'
				  + '<tr><td colspan="2">Type&nbsp;:&nbsp;' +fileType(file_.fileType)+'</tr>'
//                                       +'<tr><td><img id="img_dvfiletags" src="images/edit.png" width="10" height="10" border="0" style="cursor:pointer;" onClick=editFile("Tags","dvfiletags,""); /></td>'
//				  +'<td>Tags:&nbsp;<div id="dvfiletags" >' + tags_parased +'</div></td></tr></table>';	  


+'<tr><td><img id="img_dvfiletags" src="images/edit.png" width="10" height="10" border="0" style="cursor:pointer; display:none;" onClick=editFile("Tags","dvfiletags","'+  file_.tags+'"); /></td><td>Tags:&nbsp;<div id="dvfiletags" style="float:right; pading:1px; height:auto; width:auto; ">'+tags_parased+'</div></td></tr></table><div id="camInfoLink" style="padding-right:3px; padding-top:8px; display:none;"><a class="blue">Add camera details</a></div>';

/*
alert('<tr><td><img id="img_dvfiletags" src="images/edit.png" width="10" height="10" border="0" style="cursor:pointer;" onClick=editFile("Tags","dvfiletags","'+  file_.tags+'"); /></td><td>Tags:&nbsp;<div id="dvfiletags" style="float:right;pading:1px;">'+tags_parased+'</div></td></tr>');
*/
	document.getElementById("fileinfo").innerHTML=FileInfo_message;
	document.getElementById("fileinfo_thumb").innerHTML='<img src="'+"http://www.yabdoo.com/gallery/watch.php?showType=Capture&showSize=thumb&f="+file_.code+'" width="80" height="70" border="1" align="left" />';

if(manageris == 1)
{
    document.getElementById('filecontrol').style.display='block';
    document.getElementById('img_dvfiletitle').style.display='block';
    document.getElementById('img_filedescription').style.display='block';
    document.getElementById('img_dvfiletags').style.display='block';
}

embedCode('#000000');
}


function editFile(editType, div_name, fixedText){
	if(document.getElementById("userid").value=='0'){
		 dLoginBox(div_name,"below_left");return false;}
  
if (!fixedText)
	var val = document.getElementById(div_name).innerHTML;
else
val=fixedText;

	if (val=="No title")
		val="";
		var txt=val.replace(/ /g,'&nbsp');

         if(editType == "Description")
        var inputType='<textarea dir="rtl" type="text" style="width:175px" id="txt_'+div_name+'" value="'+val+'" rows="">'+val+'</textarea>';
         else
           inputType='<input dir="rtl" type="text" style="width:175px" id="txt_'+div_name+'" value="'+val+'">';

		document.getElementById(div_name).innerHTML = '<a id="btn_flycancel" class="blue" onclick=editFileCancel("'+editType+'","'+div_name+'")>Cancel</a>&nbsp;|&nbsp;<a id="btn_flysave" value="&nbsp;Save&nbsp;&nbsp;" onclick=editFileSave("'+editType+'","'+div_name+'") class="blue">Save</a>&nbsp;'+inputType;
	document.getElementById("txt_"+div_name).focus();
    document.getElementById('img_'+div_name).style.display = "none";
}
function editFileSave(editType,div_name){


	var txt = document.getElementById("txt_"+div_name).value;
	document.getElementById(div_name).innerHTML='<div align="center" style="width:300px;"><img height="18px" width="18px" border="0" align="middle" src="images/imgloader.gif"></div>';
	mySWF.callSWF("editFile", ["JS", document.getElementById('f').value, editType, txt, div_name]);//}
}

function FileEditedFunction(editMessage)
{
         if (editMessage.div_name=='dvfiletags')
         editMessage.editText=paraseTags(editMessage.editText);
         if(editMessage.div_name=='dvfiletitle')
         {
          document.getElementById("fileTitle").innerHTML = editMessage.editText;
          setBrowserTitle()
         }
	document.getElementById(editMessage.div_name).innerHTML = editMessage.editText;
	document.getElementById('img_'+editMessage.div_name).style.display = "block";
}
function editFileCancel(type,div_name){
	var val = document.getElementById("txt_"+div_name).value;
	txt=val.replace(/&nbsp/g,' ');
	var dv_cnt;
	if(type=='Title'){
	dv_cnt = '<span style="float:right;">&nbsp;:&nbsp;الوصف</span><span style="float:right;" id="_fileinfotitle" >'+txt+'</span>';
	
	}else{
		dv_cnt = '<span id="'+div_name+'" style="float:right;">' +txt +'</span> ';
}
              if(type=='Tags')
		document.getElementById(div_name).innerHTML = paraseTags(txt);
              else
		document.getElementById(div_name).innerHTML = txt;

           	document.getElementById('img_'+div_name).style.display = "block";

}


function getDvBlockSts(){
if(document.getElementById('ul1_LBlock').style.display=='none')
dvBlocks = new Array("myFiles","myCart","li1_9","li1_7","li1_6");
else
dvBlocks = new Array("dv_UserProfiles","dv_Albums","albumsothersfiles","ownerothersfiles","Advertisement","myFiles","myCart","li1_9","li1_7","li1_6");
	
var str = '';
	for(i=0;i<dvBlocks.length;i++){
		var sts='';
	if(document.getElementById(dvBlocks[i]).style.display == 'block' || document.getElementById(dvBlocks[i]).style.display != 'none'){
	   if(i==dvBlocks.length-1)
	      str+=dvBlocks[i];
	   else
	     str+=dvBlocks[i]+',';
	 }
	}

//alert(str);

  mySWF.callSWF("setActiveDiv", [str]); 
return str;
}


function fileAddClick(thumb)
{
     alert("file: " + thumb);

    // document.getElementById("QueueFiles_D").innerHTML=BuildFileItem(file_,i);
}


function switchSection(section)
{
	
  var sectionDivArray= new Array("home_div", "inner_div", "dv_Gallery_Manager");
  for (var i=0; i<sectionDivArray.length; i++)
  {
      document.getElementById(sectionDivArray[i]).style.display="none";
  }
  document.getElementById(section).style.display="block";
}

function navigateToHome()
{
    //window.location = "index.php";
  //document.getElementById("inner_div").style.display = "none";
 //document.getElementById('home_div').style.display = "block";
  section="home";
  StartLoading();
}


function fillType(galleryTyp, section)
{

if(updatedGalleryType!="")
{
//alert("updatedGalleryType: " + updatedGalleryType);
galleryTyp=updatedGalleryType;
}

//alert("galleryType:-  " + galleryTyp);

var galleryTypArray=galleryTyp.split(',');
if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

//alert("indexOf2:  " + galleryTypArray.indexOf('2'));
//alert("indexOf1:  " + galleryTypArray.indexOf('1'));
//alert("indexOf3:  " + galleryTypArray.indexOf('3'));

  var dv_content;
	
  dv_content='<div align="center" style="margin-bottom:8px; padding-bottom:20px;">';

  if(galleryTypArray.indexOf('2') >-1)
  {
  dv_content+='<div class="field switch"><label id="videoBtn" name="srh_video" value="video" class="cb-enable selected"><span>فيديو</span></label><label class="cb-disable "><span>Off</span></label><input type="checkbox" name="srh_video" id="srh_video" class="checkbox" checked="true" value="video" style="display:none">	</div>';
  }
  else
  {
  dv_content+='<div class="field switch"><label id="videoBtn" name="srh_video" value="video" class="cb-enable"><span>فيديو</span></label><label class="cb-disable selected"><span>Off</span></label><input type="checkbox" name="srh_video" id="srh_video" class="checkbox" checked="false" value="video" style="display:none">	</div>';
  }
  if(galleryTypArray.indexOf('1') >-1)
  {
  dv_content+='<div class="field switch"><label id="photoBtn" name="srh_photo" value="photo" class="cb-enable selected"><span>صور</span></label><label class="cb-disable "><span>Off</span></label><input type="checkbox" name="srh_photo" id="srh_photo" class="checkbox" checked="true" value="photo" style="display:none"></div>';
  }
  else
  {
  dv_content+='<div class="field switch"><label id="photoBtn" name="srh_photo" value="photo" class="cb-enable"><span>صور</span></label><label class="cb-disable selected"><span>Off</span></label><input type="checkbox" name="srh_photo" id="srh_photo" class="checkbox" checked="false" value="photo" style="display:none"></div>';
  }
  if(galleryTypArray.indexOf('3') >-1)
  {  
  dv_content+='<div class="field switch"><label id="othersBtn" name="srh_others" value="others" class="cb-enable selected"><span>أخرى</span></label><label class="cb-disable "><span>Off</span></label><input type="checkbox" name="srh_others" id="srh_others" class="checkbox" checked="true" value="others" style="display:none"></div>';
  }
  else
  {
  dv_content+='<div class="field switch"><label id="othersBtn" name="srh_others" value="others" class="cb-enable"><span>أخرى</span></label><label class="cb-disable selected"><span>Off</span></label><input type="checkbox" name="srh_others" id="srh_others" class="checkbox" checked="false" value="others" style="display:none"></div>';
  }

  dv_content+='</div>';

document.getElementById("dv_fileType").innerHTML = "";
document.getElementById("dv_fileType_inner").innerHTML = "";
//document.getElementById(section).innerHTML = dv_content;

if(section=="home")	
  YAHOO.util.Dom.get("dv_fileType").innerHTML = dv_content;
else if(section=="inner")
 YAHOO.util.Dom.get("dv_fileType_inner").innerHTML = dv_content;

//alert("photo: " + document.getElementById('srh_photo').checked +", video: "+ document.getElementById('srh_video').checked +", Others: "+ document.getElementById('srh_others').checked);
$("div#dv_advanceSearch").trigger("myCustomEvent");
//fillTypeClick();

}

function panelSettings(id)
{
	var dv_content='<div style="margin-bottom:5px;">Display: <select name="settingslist" class="combo"><option>Thumb Only</option><option>Description only</option><option>Thumb with description</option></select></div><div style="margin-bottom:5px;">Rows &nbsp;&nbsp;: <select name="settingslist" class="combosmall"><option>1</option><option>2</option><option>3</option><option selected>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option></select></div><div style="margin-bottom:5px;">Sort by: <select name="settingslist" class="combo"><option>File Name</option><option>Date Modified</option><option>File Type</option><option>Size</option><option>Most Viewed</option><option>Most Commented</option></select></div><input name="button" type="submit" class="btn" id="button" value="Submit" style="margin-left:52px; margin-top:5px;"  /><input name="button" type="submit" class="btn" id="button" value="Cancel" style="margin-top:5px;" onClick=JAVASCRIPT:ShowHidePanel("'+id+'") /></div>';
            
document.getElementById(id).innerHTML = dv_content;
document.getElementById(id).style.display = "block";
}


function updateEmbedImgSize(size)
{
   //alert(size);
   var filecode = document.getElementById("f").value;
   document.getElementById('link_code').value="http://www.yabdoo.com/gallery/watch.php?f="+filecode+"&showSize="+size;
}

function updateEmbedVidSize(size)
{
   //alert(size);
   var filecode = document.getElementById("f").value;
var shwType=document.getElementById('vidTyp').value;
var embdType;
if(document.getElementById('vidReal').checked==true)
embdType="";
else if(document.getElementById('vidThumb').checked==true)
embdType=document.getElementById('vidThumb').value;
   document.getElementById('link_code').value="http://www.yabdoo.com/gallery/watch.php?f="+filecode+"&showType="+shwType+"&showSize="+embdType;
}


function embedCode(clr){
	/*FOR W AND H */
	var w='440';var h='365';
	var e = document.getElementById("ddl_embdsize");
	if(e.options[e.selectedIndex].value != '0'){
		var wh = e.options[e.selectedIndex].value;
		val = wh.split('_');w = val[0];h=val[1];
	}
	/*FOR W AND H */
	var RltdVideo ='0';
	if(document.getElementById("rltd_video").checked==true){RltdVideo='1';}
	var PrvcyMode ='0';
	if(document.getElementById("prvcy_mode").checked==true){PrvcyMode='1';}
	var PlayHd ='0';
	if(document.getElementById("play_hd").checked==true){PlayHd='1';}
	if(document.getElementById('plyr_border').checked==true){
		document.getElementById("playerBorder0").style.border = "2px solid "+clr;
		border = "2px solid "+clr;
	}else{
             document.getElementById("playerBorder0").style.border = "0px";
             border = "0px";}
	qstr = document.getElementById("f").value;
	var EmbedCode = '<object width="'+w+'" height="'+h+'">';
	 EmbedCode +='<param value="noscale" name="scale">';
	 EmbedCode +='<param value="TL" name="salign"><param value="opaque" name="wmode">';
	 EmbedCode +='<param value="http://www.yabdoo.com/v/'+qstr+'&hd='+PlayHd+'&rel='+RltdVideo+'&pm='+PrvcyMode+'&border='+border+'" name="flashVars">';
	 EmbedCode +='<embed src="http://www.yabdoo.com/v/'+qstr+'&hd='+PlayHd+'&rel='+RltdVideo+'&pm='+PrvcyMode+'&border='+border+'"';
	 EmbedCode +='type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="405"></embed></object>';
	document.getElementById("embed_code").value= EmbedCode;
}


function writePages (trecords,n_links,n_index,fnarr) {
	//trecords =100;
	//n_index = 1;
	n_pages = Math.ceil(trecords/9);
var dv_cnts = '',fn='';
if(fnarr){
var sp = fnarr.split(',');
	for(var i=0;i<sp.length;i++){
	fn+=sp[i];
	if(i==0)fn+='("';
	else fn+='","';
}}


//dv_cnts+='<table cellpadding="3" cellspacing="0" border="0" align="center"><tr><td>'+trecords+"-"+n_links+"-"+n_index+"-"+fnarr;
dv_cnts+='<table cellpadding="3" cellspacing="0" border="0" align="center"><tr><td>';
//dv_cnts+='<label class="blue">Tottal records&nbsp;:&nbsp;'+trecords+'.</label>&nbsp;&nbsp;';	
	if (n_index != 1)
		dv_cnts+='<a onclick='+fn+'1"); title="Go to first page" style="color:#0066FF;border:1px solid #3C8DBE;font-size:11px">&nbsp;1&nbsp;</a>&nbsp;<a onclick='+fn+(parseInt(n_index)-1)+'"); title="Go to previous page" style="color:#0066FF;border:1px solid #666666;font-size:11px">&nbsp;<&nbsp;</a></td>';
	//dv_cnts+='<td><label class="blue">Page ' + n_index + ' of ' + n_pages + '.</label></td>';

	if (n_links) {
		if (n_links > n_pages)
			n_links = n_pages;
			dv_cnts+='<td>';
		var n_sideLinks = Math.floor((n_links - 1) / 2),
			n_firstLink, n_lastLink;
		
		if (n_index + n_sideLinks >= n_pages) {
			n_firstLink = n_pages - n_links + 1;
			n_lastLink = n_pages;
		}else if (n_index - n_sideLinks <= 0) {
			n_firstLink = 1;
			n_lastLink = n_links;
		}else {
			n_firstLink = n_index - n_sideLinks;
			n_lastLink = n_firstLink + n_links - 1;
		}
		for (var i = n_firstLink; i <= n_lastLink; i++)
			dv_cnts+=i == n_index ? i + ' ' : '<a  onclick='+fn+i+'"); title="Go to page ' + i + '" style="color:#0066FF;border:1px solid #666666;font-size:11px">&nbsp;' + i + '&nbsp;</a> ';
		dv_cnts+='</td>';
	}
	if (n_index != n_pages)
		dv_cnts+='<td><a onclick='+fn+(parseInt(n_index)+1)+'"); title="Go to next page" style="color:#0066FF;border:1px solid #666666;font-size:11px">&nbsp;>&nbsp;</a>&nbsp;<a onclick='+fn+n_pages+'"); title="Go to last page" style="color:#0066FF;border:1px solid #3C8DBE;font-size:11px">&nbsp;'+n_pages+'&nbsp;</a>';
	dv_cnts+='</td></tr></table>';

	return dv_cnts;
}


function userExistence(type,value)
{
mySWF.callSWF("userExistence", ["JS", type, value]); 
}


function viewCustomizePanel()
{
popup("popUpDiv");
//document.getElementById("customize").style.display="bock";
document.getElementById("popUpDiv").innerHTML='<div id="customizeBlocks" style="width:350px;"><div><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="ptl">&nbsp;</td><td class="hd">Customize Page</td><td width="25" class="hd"><a onClick=JAVASCRIPT:hidePopup("popUpDiv")><img src="images/aqua-hd-close2.gif" width="25" height="15" border="0" /></a></td><td class="ptr">&nbsp;</td></tr></table></div><div class="bd"><div class="yui-skin-sam" ><div id="cellediting" ></div></div></div></div>';

//customizeyuiClick();
	YAHOO.example.InlineCellEditing = function() {
	var myColumnDefs = [{key:"div_id", hidden: true, isPrimaryKey:'true'},
	 {key:"lbl_name", label:"Name"},
          {key:"status", label:"Active", formatter: "checkbox"}];
	 //{key:"status", label:"Active", editor: new YAHOO.widget.RadioCellEditor({radioOptions:["yes","no"],disableBtns:true})}];
			getCustomizeCke(); 
			var getcke = YAHOO.util.Cookie.get("customizeCkeData");
			jsondata = getJSon(getcke);
			var myDataSource = new YAHOO.util.DataSource(jsondata);
	myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
	myDataSource.connXhrMode = "queueRequests";
	myDataSource.responseSchema = {
		resultsList: "customize",fields: ["div_id","lbl_name","status"]
	};
	var myDataTable = new YAHOO.widget.DataTable("cellediting", myColumnDefs, myDataSource, {});
	var highlightEditableCell = function(oArgs) {
		var elCell = oArgs.target;
		if(YAHOO.util.Dom.hasClass(elCell, "yui-dt-editable")) {
			this.highlightCell(elCell);
		}
	};
				myDataTable.subscribe('checkboxClickEvent', function(oArgs){
					//Event.preventDefault(oArgs.event);
				    var elCheckbox = oArgs.target;
					var newValue = elCheckbox.checked;
				    var record = this.getRecord(elCheckbox);
					var recordIndex = this.getRecordIndex(record);
					var recordKey = record.getData('lbl_name');
					submit(recordKey,recordIndex, function(accept) {
					});
				});

				var submit = function(recordKey,recordIndex) {
					//alert(recordKey);
				};

	myDataTable.subscribe("cellMouseoverEvent", highlightEditableCell);
	myDataTable.subscribe("cellMouseoutEvent", myDataTable.onEventUnhighlightCell);
	myDataTable.subscribe("cellClickEvent", myDataTable.onEventShowCellEditor);
	var myHandler = function(oArgs) {
	/* TO SET THIS COOKIE FOR FIRST CUSTOMIZATION */
	var oEditor = oArgs.editor;
	var newData = oArgs.newData;
	var oldData = oArgs.oldData;
	var column = oArgs.editor.getColumn();
	var record = oArgs.editor.getRecord();
	switch(column.key){
		case "status":
			if(newData == 'yes'){
				var id = getDtVal(this,record);
				YAHOO.util.Cookie.set(id+'_sts', newData, { path: "/", expires: new Date(getExpDate(365,24,60)) });
			}else{
				var id = getDtVal(this,record);
				YAHOO.util.Cookie.set(id+'_sts', newData, { path: "/", expires: new Date(getExpDate(365,24,60)) });
			}	
		break;
		default:
	}
         sendCutomizeQuery();
	getCustomizeCke();
	}
	myDataTable.subscribe("editorSaveEvent", myHandler);			
	return {
		oDS: myDataSource,oDT: myDataTable};}();

}

/* TO GET SELECTED DATATABLE ROW VALUES */
var getDtVal = function(datatable,record) {
	var val = '';
	var cols = datatable.getColumnSet().keys;
	for (var i = 0; i < cols.length; i++) {
		if (cols[i].isPrimaryKey) {val += escape(record.getData(cols[i].key));}
	}
	return val;

};
/* END : CUSTOMIZATION : coded by sony */

function gotMessage(text)
{
	document.getElementById('debuging').innerHTML=document.getElementById('debuging').innerHTML+"\n\n\n"+text.text;
//<textarea name="debuging" id="debuging" rows="40" cols="52" ></textarea>

}


var currentPage;
function PreparePlay(playerid)
{
/*

*/
return true;
}


function customize(section){

var dvcnt='<span id="show-dialog-2" onClick="JAVASCRIPT:viewCustomizePanel()" class="blue" style="cursor:pointer;"><img src="images/tool.gif" width="20" height="18" align="absmiddle" border="0">تخصيص الصفحة</span><br/><div id="filetype_loading" align="left" style="margin-top:4px; width:100%; background-color:#FFFF99; color:#990000; height:22px; font-size:11px; display:none;"></div>';

if(section=='home'){
document.getElementById("loaderHome").innerHTML=dvcnt;
document.getElementById("LoaderInner").innerHTML='';
}else{
document.getElementById("LoaderInner").innerHTML=dvcnt;
document.getElementById("loaderHome").innerHTML='';


}
//customizeyuiClick();
}


function StartLoading()
{

var QueryArray=URLArray();
var section = QueryArray['section'];


if (!section)
section="home";

if (loadedBolean==false)
{
//fillType('1,2',  'home');
//fillType('1,2',  '');
}

if (section=="home")
{
document.title="يابدوو - عالمك";
switchSection("home_div");
fillType('1,2',  'home');

  if (currentPage != "home")
  {
   //PreparePlay(1);
   currentPage="home";
  }
    mySWF.callSWF("homePage", ["JS", 7,5,1]); 
}
else
{
switchSection("inner_div");
fillType('1,2',  'inner');

if (currentPage != "inner")
{
//var prepaid=PreparePlay("");
currentPage="inner";
}
}
customize(section);
}


function sendCutomizeQuery()
{
 // alert("customize Query.....");
}
