﻿function solicValidation() 
{
	var chk;
	chk=true;
	
		form1.FileName.style.backgroundColor="white";
		form1.width.style.backgroundColor="white";
		form1.Mtitle.style.backgroundColor="white";
		form1.height.style.backgroundColor="white";
		form1.Mdetails.style.backgroundColor="white";
	
	if(form1.FileName.value == null || form1.FileName.value =="" ||  form1.FileName.value ==" ") {
		chk = false;
		alert("لطفا فايل را انتخاب نمائيد\n\nPlease choose the file name");
		form1.FileName.style.backgroundColor="pink";
		}
	else if(form1.Mtitle.value == null || form1.Mtitle.value =="" ||  form1.Mtitle.value ==" ") {
		chk = false;
		alert("لطفا عنوان را مشخص نمائيد\n\nPlease fill in the title field");
		form1.Mtitle.style.backgroundColor="pink";
		}
	else if(!isInteger(form1.width.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 800 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.width.style.backgroundColor="pink";
		}
	else if(!isInteger(form1.height.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 899 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.height.style.backgroundColor="pink";
		}
	else if(form1.Mdetails.value == null || form1.Mdetails.value =="" ||  form1.Mdetails.value ==" ") {
		chk = confirm("اطلاعات تكميلي پر نشده است\nبراي ارسال اطلاعات اطمينان داريد؟\n\nSome fields have not filled out.\nAre you sure to send information?");
		form1.Mdetails.style.backgroundColor="pink";
		}
		
	if(chk)
		return true;
	else
		return false;
}

function solicDimValidation() 
{
	var chk;
	chk=true;
	
		dimForm.width.style.backgroundColor="white";
		dimForm.height.style.backgroundColor="white";
	
	if(dimForm.width.value == null || dimForm.width.value =="" ||  dimForm.width.value ==" ") {
		chk = false;
		alert("لطفا فايل را انتخاب نمائيد\n\nPlease choose the file name");
		dimForm.width.style.backgroundColor="pink";
		}
	else if(dimForm.height.value == null || dimForm.height.value =="" ||  dimForm.height.value ==" ") {
		chk = false;
		alert("لطفا عنوان را مشخص نمائيد\n\nPlease fill in the title field");
		dimForm.height.style.backgroundColor="pink";
		}
	else if(!isInteger(dimForm.width.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 800 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.width.style.backgroundColor="pink";
		}
	else if(!isInteger(dimForm.height.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 899 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.height.style.backgroundColor="pink";
		}
		
	if(chk)
		return true;
	else
		return false;
}

function solicEditValidation() 
{
	var chk;
	chk=true;
	
		form1.width.style.backgroundColor="white";
		form1.Mtitle.style.backgroundColor="white";
		form1.height.style.backgroundColor="white";
		form1.Mdetails.style.backgroundColor="white";
	
	if(form1.Mtitle.value == null || form1.Mtitle.value =="" ||  form1.Mtitle.value ==" ") {
		chk = false;
		alert("لطفا عنوان را مشخص نمائيد\n\nPlease fill in the title field");
		form1.Mtitle.style.backgroundColor="pink";
		}
	else if(!isInteger(form1.width.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 800 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.width.style.backgroundColor="pink";
		}
	else if(!isInteger(form1.height.value)) {
		chk = false;
		alert("لطفا از اعداد بين 100 تا 899 استفاده نمائيد\n\nPlease fill in numbers between 100 to 800.");
		form1.height.style.backgroundColor="pink";
		}
	else if(form1.Mdetails.value == null || form1.Mdetails.value =="" ||  form1.Mdetails.value ==" ") {
		chk = confirm("اطلاعات تكميلي پر نشده است\nبراي ارسال اطلاعات اطمينان داريد؟\n\nSome fields have not filled out.\nAre you sure to send information?");
		form1.Mdetails.style.backgroundColor="pink";
		}
		
	if(chk)
		return true;
	else
		return false;
}

function isInteger(s)
{   var i;
	if(s.length != 3)
		return false;
    var c = s.charAt(0);
    if ((c < "1") || (c > "8"))
    	return false;
    for (i = 1; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if ((c < "0") || (c > "9")) return false;
    }
    // All characters are numbers.
   	if(s < 100	&& s > 800)
		return false;

    return true;
}

function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }
   if(!tStart)
      tStart   = new Date();
   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();
   tDate.setTime(tDiff);
   theTime = "" + tDate.getMinutes() + ":" + tDate.getSeconds();
   timerID = setTimeout("UpdateTimer()", 500);
   
    /* Report for debug
	reporter.innerText +=  "----" + document.MediaPlayer.playState + "-";
	reporter.innerText +=  parseInt(posi) + "-";
	reporter.innerText +=  parseInt(document.MediaPlayer.currentposition) + "-";
	reporter.innerText +=  i + "-";
	*/
	
   if(document.MediaPlayer.playState!=0) {
	   if(parseInt(posi) == parseInt(document.MediaPlayer.currentposition)) {
			if(i<speedtime) {
				i++;
				}
			else {
				i = 0;
				document.MediaPlayer.play();
				posi = -1.0;
				}
		}
		else {
			i = 0;
			document.MediaPlayer.play();
			posi = document.MediaPlayer.currentposition;
			}
	}

}

function Start() {
   tStart   = new Date();
   theTime = "00:00";
   timerID  = setTimeout("UpdateTimer()", 1000);
}

function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   tStart = null;
}
function Reset() {
   tStart = null;
   theTime = "00:00";
}

function Speed() {
	switch (true) {
		case Cspeed[0].checked:
			speedtime = 10;
			type = Cspeed[0].value;
			break;
		case Cspeed[1].checked:
			speedtime = 30;
			type = Cspeed[1].value;
			break;
		case Cspeed[2].checked:
			speedtime = 60;
			type = Cspeed[2].value;
			break;
		case Cspeed[3].checked:
			speedtime = 100;
			type = Cspeed[3].value;
			break;
		default:
			speedtime = 30;
			break;
	}
	alert("انتخاب شد"+type+"سرعت متناسب با");
}
function chgDim() {
	MediaPlayer.width = dimForm.width.value;
	MediaPlayer.height = dimForm.height.value;
	alert("ابعاد جديد اعمال شد");
}
function resetDim() {
	MediaPlayer.width = defaultWidth;
	MediaPlayer.height = defaultHeight;
	alert("ابعاد پيش فرض اعمال شد");
}
function consstate() {
if(dimForm.cons.checked)
	dimForm.height.disabled = true;
else
	dimForm.height.disabled = false;
}

function setHeight() {
 if(dimForm.cons.checked) {
	var x = dimForm.width.value;
	var y = (defaultHeight*x)/defaultWidth;
	dimForm.height.value = parseInt(y);
 }
}

