// JavaScript Document
function open_calendar_window(mode)
{
window.open("includes/calendar_popup.php?mode="+mode,"calendar","width=203,height=210,top=200,left=560,scrollbars=no");
}


function video_preview(file_name)
{
window.open("video_preview.php?file_name="+file_name,"vid_preview","width=500,height=380,top=100,left=250,scrollbars=yes;resize=yes");
}

function image_preview(file_name)
{
window.open("image_preview.php?file_name="+file_name,"img_preview","width=500,height=420,top=100,left=250,scrollbars=yes;resize=yes");
}

function start_date(d)
{
split_date="";
split_date=d.split("-");

frm.start_date.value=split_date[1]+"-"+split_date[2]+"-"+split_date[0];
}

function end_date(d)
{
split_date="";
split_date=d.split("-");

frm.end_date.value=split_date[1]+"-"+split_date[2]+"-"+split_date[0];
}

function package_start_date(d)
{
split_date="";
split_date=d.split("-");
frm.package_start_date.value=split_date[1]+"-"+split_date[2]+"-"+split_date[0];
}

function package_end_date(d)
{
split_date="";
split_date=d.split("-");
frm.package_end_date.value=split_date[1]+"-"+split_date[2]+"-"+split_date[0];
}


function generate_upload(loop)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
i=0;
upload_contents="";
upload_contents=upload_contents+"<table width=100% border=0  cellpadding=0 cellspacing=0 >";
for(i=0;i<loop;i++)
{
upload_contents=upload_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
upload_contents=upload_contents+"<td><input name=image"+i+" type=file size=36</td></tr></table></td></tr>";
}
upload_contents=upload_contents+"</table>";
uploads.innerHTML=upload_contents;
}
}

function generate_upload_with_label(loop)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
i=0;
upload_contents="";
upload_contents=upload_contents+"<table width=100% border=0  cellpadding=2 cellspacing=2>";
for(i=0;i<loop;i++)
{
upload_contents=upload_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0>";
upload_contents=upload_contents+"<tr><td width=15% class=normal_text align=left>Label: "+(i+1)+" </td><td align=left><input name=label_"+i+" type=text size=57></td></tr>";
upload_contents=upload_contents+"<tr><td width=15% class=normal_text align=left>File:  "+(i+1)+" </td><td align=left><input name=image"+i+" type=file size=44></td></tr>";
upload_contents=upload_contents+"</table></td></tr>";
}
upload_contents=upload_contents+"</table>";
uploads.innerHTML=upload_contents;
}
}

function generate_categories(loop)
{
if(loop<=0)
frm.categories_num.value=1;
else
frm.categories_num.value=loop;

if(loop>0)
{
i=0;
category_contents="";
category_contents=category_contents+"<table width=100% border=0  cellpadding=0 cellspacing=0 >";
for(i=0;i<loop;i++)
{
category_contents=category_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
category_contents=category_contents+"<td width=20% class=normal_text>Category "+(i+1)+"</td><td><input name=category"+i+" type=text size=54></td></tr></table></td></tr>";
}
category_contents=category_contents+"</table>";
categories.innerHTML=category_contents;
}
}

function generate_packages(loop)
{
if(loop<=0)
frm.packages_num.value=1;
else
frm.packages_num.value=loop;

if(loop>0)
{
i=0;
package_contents="";
package_contents=package_contents+"<table width=100% border=0  cellpadding=0 cellspacing=0 >";
for(i=0;i<loop;i++)
{
package_contents=package_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
package_contents=package_contents+"<td width=20% class=normal_text style=padding-left:30>Type "+(i+1)+"</td><td><input name=package_type"+i+" type=text size=54></td></tr></table></td></tr>";
}
package_contents=package_contents+"</table>";
types.innerHTML=package_contents;
}
}

function CreateControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL)
{
  var d = document.getElementById(DivID);
  contents="";
  contents=contents+"<object classid='"+CLSID+"' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' id='"+ObjectID+"' width='"+WIDTH+"' height='"+HEIGHT+"'>";
  contents=contents+"<param name='allowScriptAccess' value='sameDomain' />";
  contents=contents+"<param name='movie' value='"+URL+"' />";
  contents=contents+"<param name='loop' value='false' />";
  contents=contents+"<param name='menu' value='false' />";
  contents=contents+"<param name='quality' value='high' />";
  contents=contents+"<param name='wmode' value='transparent' />";
  contents=contents+"<param name='bgcolor' value='#ffffff' />";
  contents=contents+"<embed src='"+URL+"' loop='false' menu='false' quality='high' wmode='transparent' bgcolor='#ffffff'  width='"+WIDTH+"' height='"+HEIGHT+"' name='"+ObjectID+"' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
  contents=contents+"</object>";
      
  d.innerHTML =contents;
}

function delete_news()
{
	return_confirm=confirm("Are you sure that you want to delete the selected news?");
	if(return_confirm==true)
	{
	 	frm.delete_news_identification.value=1;
		frm.submit();
	}
}

function delete_one_news(id)
{
	return_confirm=confirm("Are you sure that you want to delete this news?");
	if(return_confirm==true)
	{
		window.location="news_details.php?id="+id+"&delete_news=1";
	}
}

function delete_faqs()
{
	return_confirm=confirm("Are you sure that you want to delete the selected FAQs?");
	if(return_confirm==true)
	{
		frm.submit();
	}
}

function delete_one_faq(id)
{
	return_confirm=confirm("Are you sure that you want to delete this FAQ?");
	if(return_confirm==true)
	{
		window.location="faq_details.php?id="+id+"&delete_faq=1";
	}
}

function delete_categories()
{
	return_confirm=confirm("Are you sure that you want to delete the selected categories?");
	if(return_confirm==true)
	{
		frm.delete_categories_identification.value=1;
		frm.submit();
	}
}

function delete_forms(id)
{
	return_confirm=confirm("Are you sure that you want to delete this FORM?");
	if(return_confirm==true)
	{
		window.location="forms.php?id="+id+"&delete_form=1";
	}
}

function delete_packages()
{
	return_confirm=confirm("Are you sure that you want to delete the selected Packages?");
	if(return_confirm==true)
	{
	 	frm.delete_package_identification.value=1;
		frm.submit();
	}
}

function delete_one_package(id,mode,offset)
{
	return_confirm=confirm("Are you sure that you want to delete this Package?");
	if(return_confirm==true)
	{
		window.location="package_details.php?id="+id+"&mode="+mode+"&offset="+offset+"&delete_package=1";
	}
}

function delete_package_types()
{
	return_confirm=confirm("Are you sure that you want to delete the selected Types?");
	if(return_confirm==true)
	{
	    frm.delete_package_type_identification.value=1;
		frm.submit();
	}
}

function delete_package_dates()
{
	return_confirm=confirm("Are you sure that you want to delete the selected Package Dates?");
	if(return_confirm==true)
	{
	    frm.delete_package_date_identification.value=1;
		frm.submit();
	}
}

function delete_form()
{
	return_confirm=confirm("Are you sure that you want to delete the selected Forms?");
	if(return_confirm==true)
	{
	    frm.delete_form_identification.value=1;
		frm.submit();
	}
}
function delete_one_form(id,offset)
{
	return_confirm=confirm("Are you sure that you want to delete the this Form?");
	if(return_confirm==true)
	{
		window.location="hajj_reservation_form_details.php?id="+id+"&offset="+offset+"&delete_form=1";
	}
}

function delete_hotels()
{
	return_confirm=confirm("Are you sure that you want to delete the selected Hotels?");
	if(return_confirm==true)
	{
	 	frm.delete_hotel_identification.value=1;
		frm.submit();
	}
}

function intPart(floatNum)
{
if (floatNum< -0.0000001){
return Math.ceil(floatNum-0.0000001)
}
return Math.floor(floatNum+0.0000001) 
}

function chrToIsl(current_date) {
//current_date=current_date;
split_date=current_date.split("-");

d=parseInt(split_date[2])
m=parseInt(split_date[1])
y=parseInt(split_date[0])
if ((y>1582)||((y==1582)&&(m>10))||((y==1582)&&(m==10)&&(d>14))) 
{
jd=intPart((1461*(y+4800+intPart((m-14)/12)))/4)+intPart((367*(m-2-12*(intPart((m-14)/12))))/12)-
intPart( (3* (intPart( (y+4900+ intPart( (m-14)/12) )/100) ) ) /4)+d-32075
} else 
{
jd = 367*y-intPart((7*(y+5001+intPart((m-9)/7)))/4)+intPart((275*m)/9)+d+1729777
}
l=jd-1948440+10632
n=intPart((l-1)/10631)
l=l-10631*n+354
j=(intPart((10985-l)/5316))*(intPart((50*l)/17719))+(intPart(l/5670))*(intPart((43*l)/15238))
l=l-(intPart((30-j)/15))*(intPart((17719*j)/50))-(intPart(j/16))*(intPart((15238*j)/43))+29
m=intPart((24*l)/709)
d=l-intPart((709*m)/24)
y=30*n+j-30

return y;
}